Differences

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

Link to this comparison view

Both sides previous revision Previous revision
cs-142:99-bottles-on-milk [2016/09/15 19:58]
kseppi
cs-142:99-bottles-on-milk [2016/09/15 20:07] (current)
kseppi
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 (== 2) { + int remainingBottles = i - 1
- cout ​<< i - 1 << " bottle of milk on the wall.\n\n";+ if (remainingBottles ​== 1) { 
 + cout << "bottle of milk on the wall." ​<< endl << endl;
  }  }
- else if (== 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 20:07 by kseppi
Back to top
CC Attribution-Share Alike 4.0 International
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0