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

是这样的,想请教一下,怎样用C语言编写"输入一个字符串,将其中的大写字母改小写,然后在将其小写改为大写"
最新回答
快乐至上

2024-10-14 06:34:58

#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[]);
}
退场

2024-10-14 01:45:45

#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
视而不见

2024-10-14 06:23:47

deal(char str[])
{
while (*str != 0) {
if (isupper(*str)) { *str = toupper(*str); }
else { *str = tolower(*str); }
str++;
}
}
花开不败才是姿态

2024-10-14 02:22:40

------------------------------------
经过运行
#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");
}
不要忘記

2024-10-14 03:34:14

减32就可以了