#include using namespace std; void wr_number(int n); void wr_bottles(int n); void wr_tens(int n); void wr_units(int n); void wr_Units(int n); int main() { int n=99; while(n > 0){ wr_number(n); wr_bottles(n); cout << " of beer on the wall,\n"; wr_number(n); wr_bottles(n); cout << " of beer,\n"; cout << "Take one down, pass it around,\n"; n--; wr_number(n); wr_bottles(n); cout << " of beer on the wall.\n\n"; } return 0; } void wr_bottles(int n){ if ( n == 1) cout << " bottle"; else cout << " bottles"; } void wr_number(int n){ if (n == 0) cout << "Zero"; else {if ( n < 20 ) wr_Units(n); else { int tens = n/10, units = n%10; wr_tens(tens); if(units != 0) { cout << "-"; wr_units(units); } } } } void wr_tens(int n){ switch(n){ case 2: cout << "Twenty";break; case 3: cout << "Thirty";break; case 4: cout << "Forty";break; case 5: cout << "Fifty";break; case 6: cout << "Sixty";break; case 7: cout << "Seventy";break; case 8: cout << "Eighty";break; case 9: cout << "Ninety";break; default: cerr << "Bad tens!!\n";exit(1); } } void wr_units(int n){ switch(n){ case 1: cout << "one";break; case 2: cout << "two";break; case 3: cout << "three";break; case 4: cout << "four";break; case 5: cout << "five";break; case 6: cout << "six";break; case 7: cout << "seven";break; case 8: cout << "eight";break; case 9: cout << "nine";break; default: cerr << "Bad units!!\n";exit(1); } } void wr_Units(int n){ switch(n){ case 1: cout << "One";break; case 2: cout << "Two";break; case 3: cout << "Three";break; case 4: cout << "Four";break; case 5: cout << "Five";break; case 6: cout << "Six";break; case 7: cout << "Seven";break; case 8: cout << "Eight";break; case 9: cout << "Nine";break; case 10: cout << "Ten";break; case 11: cout << "Eleven";break; case 12: cout << "Twelve";break; case 13: cout << "Thirteen";break; case 14: cout << "Fourteen";break; case 15: cout << "Fifteen";break; case 16: cout << "Sixteen";break; case 17: cout << "Seventeen";break; case 18: cout << "Eighteen";break; case 19: cout << "Nineteen";break; default: cerr << "Bad Units!!\n"; exit(1); } }