Guest User

Untitled

a guest
May 21st, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. #include <iostream>
  2. #include <map>
  3. #include <string>
  4. using namespace std;
  5.  
  6.  
  7.  
  8. map<int,string> Ones;
  9. map<int,string> Tens;
  10.  
  11. int main()
  12. {
  13. int iNoOfBottles = 99;
  14.  
  15. string bob = " bottles of beer";
  16. string otw = " on the wall!";
  17. string fall = "If one of those bottles should happen to fall\nThere'll be ";
  18.  
  19. Ones[0] = "zero";
  20. Ones[1] = "one";
  21. Ones[2] = "two";
  22. Ones[3] = "three";
  23. Ones[4] = "four";
  24. Ones[5] = "five";
  25. Ones[6] = "six";
  26. Ones[7] = "seven";
  27. Ones[8] = "eight";
  28. Ones[9] = "nine";
  29.  
  30. Tens[0] = "Zero";
  31. Tens[1] = "Ten";
  32. Tens[2] = "Twenty";
  33. Tens[3] = "Thirty";
  34. Tens[4] = "Forty";
  35. Tens[5] = "Fifty";
  36. Tens[6] = "Sixty";
  37. Tens[7] = "Seventy";
  38. Tens[8] = "Eighty";
  39. Tens[9] = "Ninety";
  40.  
  41.  
  42.  
  43. while( iNoOfBottles > -1 )
  44. {
  45. string num;
  46. int iTensIndex = iNoOfBottles/10;
  47.  
  48. for( int i=9; i >= 0 ; i-- )
  49. {
  50. if( !i )
  51. {
  52. num = Tens[iTensIndex];
  53. goto PrintSong;
  54. }
  55.  
  56. if( iTensIndex == 1 )
  57. {
  58. switch(i)
  59. {
  60. case 1: num = "eleven"; break;
  61. case 2: num = "twelve"; break;
  62. case 3: num = "thirteen"; break;
  63. case 5: num = "fifteen";break;
  64. case 8: num = "eighteen"; break;
  65. default:
  66. num = Ones[i] + "teen";
  67. };
  68. }
  69. else num = (iTensIndex?Tens[iTensIndex]+"-":"")+ Ones[i];
  70.  
  71. PrintSong:
  72. cout<<num+bob+otw+"\n\n";
  73. if(num == "Zero") break;
  74. cout<<num + bob + otw + "\n" + num + bob + "\n" + fall;
  75. }
  76.  
  77. iNoOfBottles-=11;
  78. }
  79.  
  80. getchar();
  81. }
Add Comment
Please, Sign In to add comment