Wednesday, January 22, 2020

Codeforces 131A cAPS lOCK Solution in C

  1. #include <stdio.h>
  2. int main()
  3. {
  4. char ch[106];
  5. int i,j,ck=1;
  6. scanf("%s",ch);
  7. for(i=1;ch[i]!='\0';i++)
  8. {
  9. if(ch[i]>=97&&ch[i]<=122)
  10. {
  11. ck=0;
  12. break;
  13. }
  14. }
  15. if(ck==1)
  16. {
  17. if(ch[0]>=65&&ch[0]<=90)
  18. ch[0]=ch[0]+32;
  19. else
  20. ch[0]=ch[0]-32;
  21. for(j=1;ch[j]!='\0';j++)
  22. {
  23. ch[j]=ch[j]+32;
  24. }
  25. }
  26. printf("%s\n",ch);
  27. return 0;
  28. }

No comments:

Post a Comment

Codeforces 131A cAPS lOCK Solution in C

#include <stdio.h> int main () { char ch [ 106 ]; int i , j , ck = 1 ; scanf ( "%s" , ch ); ...