fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. string s;
  6. int c=0,d=0;
  7. char ch;
  8. cin >> s;
  9. int n = s.size();
  10. if(islower(s[0]))
  11. {
  12.  
  13. for(int i=1;i<n;i++)
  14. {
  15. if(isupper(s[i]))
  16. {
  17. c++;
  18. }
  19. }
  20. if(c == n-1)
  21. {
  22. s[0] = toupper(s[0]);
  23. for(int i=1;i<n;i++)
  24. {
  25. s[i] = tolower(s[i]);
  26. }
  27. cout << s << endl;
  28.  
  29. }
  30. else
  31. {
  32. cout << s << endl;
  33. }
  34.  
  35.  
  36. }
  37. else if(isupper(s[0])){
  38. for(int i=1;i<n;i++)
  39. {
  40. if(isupper(s[i]))
  41. {
  42. d++;
  43. }
  44. }
  45. if(n-1==d)
  46. {
  47. for(int i=0;i<n;i++)
  48. {
  49. s[i] = tolower(s[i]);
  50. }
  51. cout << s << endl;
  52. }
  53. else
  54. {
  55. cout << s << endl;
  56. }
  57. }
  58.  
  59. return 0;
  60. }
Success #stdin #stdout 0.01s 5320KB
stdin
LOck
stdout
LOck