您的位置:首页 > 其它

104.把字符串奇数位上的小写字母转化为大写且其他字符不变

2015-07-02 12:37 417 查看
函数fun功能是:将ss所指字符串中所有下标为奇数位置上的 转换为大写(若该位置上不是字母,则不转换)。

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
void fun(char *s)
{
int i = 1;
while (s[i] && s[i - 1])
{
if (s[i] >= 'a'&&s[i] <= 'z')
s[i] += 'A' - 'a';
i += 2;
}
}
int main()
{
char tt[51];
printf("\nPlease enter an character string within 50 characters:\n");
gets(tt);
printf("\n\nAfter chaanging the string\n\"%s\"", tt);
fun(tt);
printf("\nbecomes\n \"%s\"", tt);
system("pause");
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: