[关闭]
@Metralix 2016-10-06T07:48:21.000000Z 字数 480 阅读 671

Problem I

Language C
看清题设,只有从第二位开始全部是大写的字符串,所以我写了个函数,判断字符串是否满足这个条件
然后用for循环结合if选择结构输出结果

  1. #include<stdio.h>
  2. #include<string.h>
  3. int check(char let[])
  4. {
  5. int i;
  6. for (i=1;i<strlen(let);i++)
  7. {
  8. if(let[i]>='a'&&let[i]<='z')
  9. return(0);
  10. }
  11. return(1);
  12. }
  13. int main()
  14. {
  15. int i;
  16. char let[100];
  17. gets(let);
  18. if(0==check(let))
  19. {
  20. for(i=0;i<strlen(let);i++)
  21. printf("%c",let[i]);
  22. }
  23. else if(1==check(let))
  24. {
  25. for(i=0;i<strlen(let);i++)
  26. {
  27. if(let[i]>='a'&&let[i]<='z')
  28. printf("%c",let[i]-32);
  29. else if(let[i]>='A'&&let[i]<='Z')
  30. printf("%c",let[i]+32);
  31. }
  32. }
  33. }
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注