caps lock

Revision ru1, by skewer, 2020-02-12 14:55:00
#include <iostream>
    using namespace std;
    int main(){
        string s;
        int n=0;
        cin >> s ;
        if(s.size() == 1){
           if(s[0]<= 'z' && 'a' <= s[0]){
             s[0]-=32;
             cout <<s[0];
             return 0 ;
           }
           else if(s[0]<= 'z' && 'a' <= s[0]){

             s[0]+=32;
             cout << s[0];
             return 0;
           }
        }
        for(int i = 0 ;i < s.size(); i++ ){
           if(s[i] <= 'z' && 'a'<= s[i]){
             n++;
           }
        }
        if(n>=2){
           cout << s;
           return 0;
        }
        else{
           if(s[0]<= 'Z' && 'A'<= s[0] && n!=0){
             cout << s;
             return 0;
           } 
           for(int i = 0 ;i < s.size(); i++ ){
           if(s[i] <= 'z' && 'a'<= s[i]){
             s[i]-=32;


           }
           else {
             s[i]+=32;
           } 
           } 
             cout << s;

        }
    }

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
ru1 Russian skewer 2020-02-12 14:55:00 1061 Первая редакция (опубликовано)