fork download
  1. #include <iostream>
  2.  
  3. using std::cin;
  4. using std::cout;
  5. using std::endl;
  6.  
  7. int main() {
  8. std::string arr[] = {"SgdGhG", "ggsdghG"};
  9. int n = sizeof(arr)/sizeof(arr[0]); // get size of array
  10.  
  11. for(int i=0; i<n; i++) {
  12. std::string word = arr[i];
  13. int len = word.length();
  14. std::string new_word = "";
  15. bool first_letter = true;
  16.  
  17. for(int j=0; j<len; j++) {
  18. if(isdigit(word[j])) {
  19. continue;
  20. }
  21. if(first_letter) {
  22. new_word += toupper(word[j]);
  23. first_letter = false;
  24. }
  25. else {
  26. new_word += tolower(word[j]);
  27. }
  28. }
  29. cout << new_word << endl;
  30. }
  31. return 0;
  32. }
Success #stdin #stdout 0.01s 5520KB
stdin
asgHG haghd
stdout
Sgdghg
Ggsdghg