求程序!请看看
题:字符串反序(最多30个字符,字符串包含字母和空格)要求:1.大写变成小写
2.小写小写变成大写
3.空格不变
4.把字符串内容反序
请哪位帮个忙,谢谢
程序代码:#include <stdio.h>
#include <string.h>
main()
{
char str1[30],str2[30];
int i,j;
gets(str1);
for(i=strlen(str1)-1,j=0;i>=0;i--)
{
if(islower(str1[i]))
str2[j++]=toupper(str1[i]);
else if(isupper(str1[i]))
str2[j++]=tolower(str1[i]);
else
str2[j++]=str1[i];
}
str2[j]='\0';
puts(str2);
}

程序代码:/*-------------------------------------------------------------------------------
题:字符串反序(最多30个字符,字符串包含字母和空格)
要求:
1.大写变成小写
2.小写小写变成大写
3.空格不变
4.把字符串内容反序
--------------------------------------------------------------------------------*/
#include <stdio.h>
#include <string.h>
#define N 30
int main(void)
{
char ch[N];
char *p,*pr;
char tmp;
puts("input ch[]:\n");
gets(ch);
p=ch;
pr=p+strlen(ch)-1;
while(p<pr)
{
tmp=*p;*p=*pr;*pr=tmp;
p++;
pr--;
}
p=ch;
while(*p)
{
if(*p>='a'&&*p<='z')
{
*p-=32;
p++;
continue;
}
if(*p>='A'&&*p<='Z')
{
*p+=32;
p++;
continue;
}
p++;
}
puts(ch);
return 0;
}