Witam,
Od niedawna zacząłem C++.
Mam do napisania program - tekst piosenki 99 bottles of beer on the wall. W sumie prawie jestem zadowolony, ale brak wisienki na torcie
Mój program wygląda tak:
#include <iostream>
using namespace std;
int main()
{
for (int i=99;i>0;i--)
{
cout << i<< " bottles of beer on the wall, " <<i<< " bottles of beer"<<endl ;
cout << "Take one down, pass it around, " <<i-1<< " bottles of beer on the wall..."<<endl;
cout <<endl;
}
return 0;
}
Lub tak (myślałem że błąd jest w samym doborze rodzaju pętli):
#include <iostream>
using namespace std;
int butelki=99;
int main()
{
while (butelki>0)
{
cout << butelki<< " bottles of beer on the wall, " <<butelki<< " bottles of beer"<<endl ;
cout << "Take one down, pass it around, " <<butelki-1<< " bottles of beer on the wall..."<<endl;
cout <<endl;
butelki--;
}
return 0;
}
Problem jest z 1 linijką dla 1 zwrotki. jest tak:
Take one down, pass it around, 98 bottles of the beer on the wall...
brakuje 1 linijki...
Gdzie zrobiłem błąd?