Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /******************************************************************************
- Online C++ Compiler.
- Code, Compile, Run and Debug C++ program online.
- Write your code in this editor and press "Run" button to compile and execute it.
- *******************************************************************************/
- #include <iostream>
- using namespace std;
- int main()
- {
- string str;
- cin>>str;
- bool firstLetter; // true for lower.
- // false for upperCase.
- bool otherLetters = true;
- ///validation.
- for(int i =0; i<str.size();i++) {
- if(i == 0){
- //pirveli simbolo
- if(str[i]>='a' && str[i]<='z'){
- firstLetter = true;
- }else firstLetter = false;
- }else{
- //danarcheni
- if(str[i] <'A' || str[i]>'Z') {
- otherLetters = false;
- }
- }
- }
- //1) firstLetter == true da otherLetters = true;
- //2) firstLetter == false da otherLetters = true;
- if((firstLetter && otherLetters)
- || (!firstLetter && otherLetters)) {
- //shecvla
- for(int i =0; i<str.size();i++) {
- if(str[i]>='A' && str[i] <='Z') {
- str[i] += 'a' - 'A';
- }
- }
- str[0] += 'A' -'a';
- cout << str << endl;
- }else{
- cout << str << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement