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