##### Differences

This shows you the differences between two versions of the page.

 cs-142:99-bottles-on-milk [2016/09/15 13:58]kseppi cs-142:99-bottles-on-milk [2016/09/15 14:07] (current)kseppi Both sides previous revision Previous revision 2016/09/15 14:07 kseppi 2016/09/15 13:58 kseppi 2016/09/15 13:55 kseppi 2014/09/27 08:41 kseppi 2014/09/25 08:48 kseppi 2014/09/25 08:36 kseppi 2014/09/25 08:26 kseppi created 2016/09/15 14:07 kseppi 2016/09/15 13:58 kseppi 2016/09/15 13:55 kseppi 2014/09/27 08:41 kseppi 2014/09/25 08:48 kseppi 2014/09/25 08:36 kseppi 2014/09/25 08:26 kseppi created Line 120: Line 120: if (i == 1) { if (i == 1) { - cout << i << " bottle of milk on the wall,\n"; + cout << i << " bottle of milk on the wall," ​<< endl; - cout << i << " bottle of milk on the wall,\n"; + cout << i << " bottle of milk on the wall," ​<< endl; } } else { else { - cout << i << " bottles of milk on the wall,\n"; + cout << i << " bottles of milk on the wall," ​<< endl; - cout << i << " bottles of milk on the wall,\n"; + cout << i << " bottles of milk on the wall," ​<< endl; } } - cout << "take one down and pass it around,\n"; + cout << "take one down and pass it around," ​<< endl; - if (i == 2) { + int remainingBottles = i - 1; - cout ​<< i - 1 << " bottle of milk on the wall.\n\n"; + if (remainingBottles ​== 1) { + cout << "1 bottle of milk on the wall." ​<< endl << endl; } } - else if (i == 1) { + else if (remainingBottles ​== 0) { - cout << "no bottles of milk on the wall.\n\n"; + cout << "no bottles of milk on the wall." ​<< endl << endl; } } else { else { - cout << ​i - 1 << " bottles of milk on the wall.\n\n"; + cout << ​remainingBottles ​<< " bottles of milk on the wall." ​<< endl << endl; } } - } }
cs-142/99-bottles-on-milk.txt · Last modified: 2016/09/15 14:07 by kseppi