Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <map>
- #include <string>
- using namespace std;
- map<int,string> Ones;
- map<int,string> Tens;
- int main()
- {
- int iNoOfBottles = 99;
- string bob = " bottles of beer";
- string otw = " on the wall!";
- string fall = "If one of those bottles should happen to fall\nThere'll be ";
- Ones[0] = "zero";
- Ones[1] = "one";
- Ones[2] = "two";
- Ones[3] = "three";
- Ones[4] = "four";
- Ones[5] = "five";
- Ones[6] = "six";
- Ones[7] = "seven";
- Ones[8] = "eight";
- Ones[9] = "nine";
- Tens[0] = "Zero";
- Tens[1] = "Ten";
- Tens[2] = "Twenty";
- Tens[3] = "Thirty";
- Tens[4] = "Forty";
- Tens[5] = "Fifty";
- Tens[6] = "Sixty";
- Tens[7] = "Seventy";
- Tens[8] = "Eighty";
- Tens[9] = "Ninety";
- while( iNoOfBottles > -1 )
- {
- string num;
- int iTensIndex = iNoOfBottles/10;
- for( int i=9; i >= 0 ; i-- )
- {
- if( !i )
- {
- num = Tens[iTensIndex];
- goto PrintSong;
- }
- if( iTensIndex == 1 )
- {
- switch(i)
- {
- case 1: num = "eleven"; break;
- case 2: num = "twelve"; break;
- case 3: num = "thirteen"; break;
- case 5: num = "fifteen";break;
- case 8: num = "eighteen"; break;
- default:
- num = Ones[i] + "teen";
- };
- }
- else num = (iTensIndex?Tens[iTensIndex]+"-":"")+ Ones[i];
- PrintSong:
- cout<<num+bob+otw+"\n\n";
- if(num == "Zero") break;
- cout<<num + bob + otw + "\n" + num + bob + "\n" + fall;
- }
- iNoOfBottles-=11;
- }
- getchar();
- }
Add Comment
Please, Sign In to add comment