Advertisement
add1ctus

cAPS LOCK

Sep 30th, 2015
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     string str;
  9.     cin>>str;
  10.     bool pustenCapsLock=true;
  11.     for(int i=1;i<str.size();++i)
  12.         if(str[i]>='a')
  13.         {
  14.             pustenCapsLock=false;
  15.         }
  16.     if(pustenCapsLock)
  17.         for(int i=0;i<str.size();++i)
  18.         {
  19.             if(str[i]>='A' && str[i]<='Z')
  20.                 str[i]+=32;
  21.             else
  22.                 str[i]-=32;
  23.         }
  24.     cout<<str;
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement