C语言入门题库——大小写字母转换
Description:将输入的字符序列ABCdef转换,大写转换为小写,小写转换为大写并输出。
Input:输入仅一行,输入字符序列。
Output:输出仅一行,字符转换,大写变小写,小写变大写,其它字符不变。
Sample Input:ABC&d#ef
Sample Output:abc&D#EF
//大小写字母转换
#include<stdio.h>
int main()
{
int i;
char a[100];
gets(a);
for(i=0; a[i]!='\0'; i++)
if(a[i]>='A' && a[i]<='Z')
a[i] += 32;
else if(a[i]>='a' && a[i]<='z')
a[i] -= 32;
puts(a);
return 0;
}