Advertisement
Guest User

Untitled

a guest
Nov 29th, 2015
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <algorithm>
  5. #include <cmath>
  6. #include <map>
  7. #include <stack>
  8.  
  9. using namespace std;
  10.  
  11. int main()
  12. {
  13. string s;
  14. cin >> s;
  15. int cnt1 = 0;
  16. int cnt2 = 0;
  17. for (int i(0); i < s.size(); i++)
  18. {
  19. if (s[i] >= 'A' && s[i] <= 'Z')
  20. cnt1++;
  21. }
  22. if (s[0] >= 'a' && s[0] <= 'z')
  23. cnt2 = 1;
  24. if ((cnt2 == 1 && cnt1 == s.size() - 1) || (cnt1 == s.size()) || (s.size() == 1))
  25. {
  26. for (int i(0); i < s.size(); i++){
  27.  
  28. if (s[i] >= 'A' && s[i] <= 'Z')
  29. s[i] = s[i] - 'A' + 'a';
  30. else
  31. if (s[i] >= 'a' && s[i] <= 'z')
  32. s[i] = s[i] - 'a' + 'A';
  33. }
  34. cout << s << endl;
  35. }
  36. else
  37. cout << s << endl;
  38.  
  39.  
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement