fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. void solve(int test, string s)
  5. {
  6. for (int i = 1; i<=s.size(); i++){
  7. if (test & 1)
  8. cout << (char)(i & 1 ? toupper(s[i-1]) : tolower(s[i-1]));
  9. else
  10. cout << (char)(i & 1 ? tolower(s[i-1]) : toupper(s[i-1]));
  11. }
  12. cout << endl;
  13. }
  14.  
  15. int main()
  16. {
  17. int t;
  18. cin >> t;
  19. string s;
  20. for(int i = 1; i<=t; ++i){
  21. cin >> s;
  22. solve(i, s);
  23. }
  24. return 0;
  25. }
Success #stdin #stdout 0s 3236KB
stdin
5
sherlock
watson
moriarty
junior
computer
stdout
ShErLoCk
wAtSoN
MoRiArTy
jUnIoR
CoMpUtEr