怎样用C语言编写"输入一个字符串,将其中的大写字母改小写,然后在将其小写改为大写"

最好全部编写出来

#include<stdio.h>
main()
{
char s[];
int i=0;
for(i=0;;i++)
scanf("%c"*s[i]);
for (i=0;s[i]!='/0';i++)
{
if(s[i]>='A'&&s[i]<='Z')
s[i]+=32;/将大写字母改为小写
else
if(s[i]>='a'&&s[i]<='z')/将小写改为大写
s[i]-=32;
}
printf("%c",s[]);
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  推荐于2018-05-14
#include<stdio.h>
main()
{
char c;
while((c=getchar())!='\n')
{
if(c>='a'&&c<='z')
c=c-32;
else
if(c>='A'&&c<='Z')
c=c+32;
printf("%c",c);
}
printf("\n");
}

经本人亲自编写并测试,如有不懂请Q我172610236本回答被网友采纳
第2个回答  2007-12-13
deal(char str[])
{
while (*str != 0) {
if (isupper(*str)) { *str = toupper(*str); }
else { *str = tolower(*str); }
str++;
}
}
第3个回答  2007-12-14
------------------------------------
经过运行
#include<stdio.h>
main()
{
char a[100];//最多输入100个字符
int i,j;
printf("plsea input a[].\n");
gets(a);

for(i=0;a[i]!='\0';i++)
{
if(a[i]>='a' && a[i]<='z') a[i]=a[i]-32;else
if(a[i]>='A' && a[i]<='Z') {a[i]=a[i]+32;continue;}
}
for(i=0;a[i]!='\0';i++)
printf("%c",a[i]);
printf("\n");
}
第4个回答  2007-12-13
减32就可以了

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网