fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main() {
  6. int N;
  7. cin >> N;
  8.  
  9. string word;
  10. for (int i = 0; i < N; i++) {
  11. cin >> word;
  12.  
  13. if (word.length() > 0) {
  14. if (word[0] >= 'a' && word[0] <= 'z')
  15. word[0] = word[0] - ('a' - 'A');
  16.  
  17. if (word[word.length() - 1] >= 'A' && word[word.length() - 1] <= 'Z')
  18. word[word.length() - 1] = word[word.length() - 1] + ('a' - 'A');
  19. }
  20.  
  21. cout << word << " ";
  22. }
  23.  
  24. cout << endl;
  25.  
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 0.01s 5280KB
stdin
 
stdout