Advertisement
Guest User

Untitled

a guest
Nov 9th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int isCapsOn(string s){
  6.     for(int i = 1; i<s.size(); i++){
  7.         if(islower(s[i])){
  8.             return 0;
  9.         }
  10.     }
  11.  
  12.     return 1;
  13. }
  14.  
  15.  
  16. int main(){
  17.  
  18.     string sinp;
  19.     cin >> sinp;
  20.  
  21.     if(isCapsOn(sinp)){
  22.        
  23.         for(int i = 0; i<sinp.size(); i++){
  24.  
  25.             if( islower(sinp[i]) )
  26.                 sinp[i] = toupper(sinp[i]);
  27.  
  28.             else
  29.                 sinp[i] = tolower(sinp[i]);
  30.         }
  31.        
  32.         cout << sinp << endl;
  33.     }
  34.     else
  35.         cout << sinp << endl;
  36.  
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement