fork download
  1. #include <iostream>
  2. using namespace std;
  3. void convert(string arr[], int n){
  4. for(int i=0; i<n; i++) {
  5. std::string word = arr[i];
  6. int len = word.length();
  7. std::string new_word = "";
  8. bool first_letter = true;
  9.  
  10. for(int j=0; j<len; j++) {
  11. if(isdigit(word[j])) {
  12. continue;
  13. }
  14. if(first_letter) {
  15. new_word += toupper(word[j]);
  16. first_letter = false;
  17. }
  18. else {
  19. new_word += tolower(word[j]);
  20. }
  21. }
  22. cout << new_word << endl;
  23. }
  24. }
  25. int main() {
  26. // your code goes here
  27. int n;
  28. cin>>n;
  29. string arr[n];
  30.  
  31. for(int i =0;i<n;i++){
  32. cin>>arr[i];
  33. }
  34. convert(arr, n);
  35. return 0;
  36. }
Success #stdin #stdout 0.01s 5428KB
stdin
3
GAFgssvg jhasgdh ajjd
stdout
Gafgssvg
Jhasgdh
Ajjd