第1个回答 推荐于2018-03-10
#include<stdio.h>
void main()
{
char a[80],*p;
p=a;
scanf("%s",a);
while (*p!='\0'){
if (*p<='Z' && *p>='A') *p+=32;
p++;
}
printf("%s",a);
}
未用指针的
void main()
{
char a[80];
int i,j;
for(j=0; j<100 && a[j-1]!='#';j++)
scanf("%c",&a[j]);
for(i=0;i<j-1;i++)
{
if(('a'<=a[i] && a[i]<='z') || ('A'<=a[i] && a[i]<='Z'))
{
if('A'<=a[i] && a[i]<='Z') a[i]=a[i]+32;
else a[i]=a[i]-32;
}
printf("%c",a[i]);
}
printf("\n");
}本回答被提问者和网友采纳
第2个回答 2010-11-22
嗯,顺手写的,的确有个地方疏忽了,加个continue就没什么问题了,呵呵
#include 'stdio.h'
main()
{
char i=0,temp[100];
scanf("%s",temp);
while((temp[i++]!='\0')||i>100)
{
if((temp[i])>='a')&&(temp[i]<='z'))
{
temp[i]-=0x20;
countinue;
}
if((temp[i])>='A')&&(temp[i]<='Z'))
temp[i]+=0x20;
}
printf("%s",temp);
}