fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. string s;
  6. char ch;
  7. cin >> s;
  8. int n = s.size();
  9. if(isupper(s[0]))
  10. {
  11. for(int i=1;i<n;i++)
  12. {
  13. if(isupper(s[i]))
  14. {
  15. ch = tolower(s[i]);
  16. s[i] = ch;
  17. }
  18.  
  19. }
  20.  
  21. cout << s << endl;
  22.  
  23. }
  24. else{
  25. s[0] = toupper(s[0]);
  26. for(int i=1;i<n;i++)
  27. {
  28. if(isupper(s[i]))
  29. {
  30. ch = tolower(s[i]);
  31. s[i] = ch;
  32. }
  33.  
  34. }
  35. cout << s << endl;
  36. }
  37. return 0;
  38. }
Success #stdin #stdout 0.01s 5312KB
stdin
cAPS
stdout
Caps