소스 ¶
~cpp #include <iostream> using namespace std; void print(char *str); void print(char *str, int num); int turn = 0; int main() { char str[20]; int num = 0; while(1) { cin >> str; if(cin.peek() == '\n') { print(str); cin.get(); } else if(cin.peek() != '\n') { cin >> num; print(str, num); if(num == 0) break; } } return 0; } void print(char *str) { cout << str << endl; ++turn; } void print(char *str, int num) { int i; if(num != 0) { for(i = 0; i < turn; i++) { cout << str << endl; } } ++turn; }