Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. /******************************************************************************
  2.  
  3. Online C++ Compiler.
  4. Code, Compile, Run and Debug C++ program online.
  5. Write your code in this editor and press "Run" button to compile and execute it.
  6.  
  7. *******************************************************************************/
  8.  
  9. #include <iostream>
  10.  
  11. using namespace std;
  12.  
  13. int main()
  14. {
  15. string str;
  16. cin>>str;
  17. bool firstLetter; // true for lower.
  18. // false for upperCase.
  19. bool otherLetters = true;
  20. ///validation.
  21. for(int i =0; i<str.size();i++) {
  22. if(i == 0){
  23. //pirveli simbolo
  24. if(str[i]>='a' && str[i]<='z'){
  25. firstLetter = true;
  26. }else firstLetter = false;
  27. }else{
  28. //danarcheni
  29. if(str[i] <'A' || str[i]>'Z') {
  30. otherLetters = false;
  31. }
  32. }
  33. }
  34. //1) firstLetter == true da otherLetters = true;
  35. //2) firstLetter == false da otherLetters = true;
  36. if((firstLetter && otherLetters)
  37. || (!firstLetter && otherLetters)) {
  38. //shecvla
  39. for(int i =0; i<str.size();i++) {
  40. if(str[i]>='A' && str[i] <='Z') {
  41. str[i] += 'a' - 'A';
  42. }
  43. }
  44. str[0] += 'A' -'a';
  45. cout << str << endl;
  46. }else{
  47. cout << str << endl;
  48. }
  49.  
  50.  
  51.  
  52. return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement