fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <cctype>
  4. #include <algorithm>
  5. #include <map>
  6.  
  7. using namespace std;
  8.  
  9. int main () {
  10. map<string,int> m;
  11. m["zero"] = 0;
  12. m["one"] = 1;
  13. m["two"] = 2;
  14. m["three"] = 3;
  15. m["four"] = 4;
  16. m["five"] = 5;
  17. m["six"] = 6;
  18. m["seven"] = 7;
  19. m["eight"] = 8;
  20. m["nine"] = 9;
  21.  
  22. cout << "Enter number from 0-9 with word:" << endl;
  23. string input;
  24. getline(cin, input);
  25. transform(input.begin(), input.end(), input.begin(), ::tolower);
  26.  
  27. for (int i = 1; i <= m[input]; i++) {
  28. for (int j = 1; j <= i; j++) {
  29. cout << input << ", ";
  30. }
  31. cout << endl;
  32. }
  33.  
  34. cin.get();
  35. return EXIT_SUCCESS;
  36. }
Success #stdin #stdout 0s 3484KB
stdin
three
stdout
Enter number from 0-9 with word:
three, 
three, three, 
three, three, three,