Advertisement
muhata84

Problem 3 – Title Case

Oct 2nd, 2019
359
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include <iostream>
  2. #include <sstream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. string inPut;
  10. getline(cin, inPut);
  11.  
  12. istringstream iss (inPut);
  13. int long_string = inPut.size();
  14. string word;
  15. int counter = 0;
  16.  
  17. for(int i =0; i < long_string; i++)
  18. {
  19. if(inPut[i]== ' ')
  20. {
  21. counter++;
  22. }
  23. }
  24.  
  25. for(int i = 0; i <= counter; i++)
  26. {
  27. iss >>word;
  28. int long_word = word.size();
  29.  
  30. for(int j = 0; j <= long_word; j ++)
  31. {
  32. if(word[j]== ',')
  33. {
  34. word[j+1]= word[j+1] - 32;
  35. }
  36. }
  37.  
  38. if(word[0]>=97 && word[0]<=122)
  39. {
  40. word[0]=word[0]-32;
  41. }
  42.  
  43. cout << word<<" ";
  44. }
  45.  
  46.  
  47.  
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement