Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. void check(string word)
  5. {
  6. int len = word.length(), smallorbig = 1; // big
  7. if(len%2==1)
  8. {
  9. for(int i=0;i<len;i++)
  10. {
  11. if(i%2==0)
  12. putchar(toupper(word[i]));
  13. else putchar(tolower(word[i]));
  14. }
  15. }
  16. else
  17. {
  18. for(int i=0;i<len/2;i++)
  19. {
  20. if(i%2==0)
  21. putchar(toupper(word[i]));
  22. else putchar(tolower(word[i]));
  23. }
  24. for(int i=len/2;i<len;i++)
  25. {
  26. if(i%2==1)
  27. putchar(toupper(word[i]));
  28. else putchar(tolower(word[i]));
  29. }
  30. }
  31. }
  32.  
  33. void single(string str)
  34. {
  35. string word = "";
  36. for (auto x : str)
  37. {
  38. if (x == ' ')
  39. {
  40. check(word);
  41. cout << " ";
  42. word = "";
  43. }
  44. else
  45. word = word + x;
  46. }
  47. check(word);
  48. }
  49.  
  50. int main()
  51. {
  52. int t; cin >> t; getchar();
  53. while(t--)
  54. {
  55. string str;
  56. getline(cin, str);
  57. single(str);
  58. cout << '\n';
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement