Cześć. Napisałem taki program:
#include <iostream>
#include <cstdlib>
#include <time.h>
using namespace std;
string wait;
int konto=0, menu, select, random_number1, random_number2, random_number3, los1, los2, los3, gotowe1=0, gotowe2=0, gotowe3=0;
int main()
{
srand(time(NULL));
random_number1 = rand()%100;
random_number2 = rand()%1000;
random_number3 = rand()%100000;
cout << "Exacler" << endl;
while(menu!=1)
{
cout << endl;
cout << "1.START" << endl;
cout << "2.POMOC" << endl;
cout << "3.O PROGRAMIE" << endl;
cout << "->";
cin >> menu;
switch(menu)
{
case 2:
cout << "Celem gry jest uzbieranie kwoty wygenerowanej przez program." << endl;
cout << "Nie moze byc mniejsza ani wyzsza!" << endl;
break;
case 3:
cout << "Autor:Mateusz Wolarz" << endl;
cout << "Uzyty kompilator:CodeBlocks" << endl;
cout << "Napisany na potrzeby:Wlasne" << endl;
cout << "Stopien dostepnosci:Prywatny" << endl;
cout << "Udostepniony:Nie" << endl;
break;
}
}
cout << "Uzbieraj:" << random_number1 << " ," << random_number2 << " ," << random_number3 << endl;
while((gotowe1!=1)&&(gotowe2!=1)&&(gotowe3!=1))
{
if (gotowe1=1)
{
cout << "1=Gotowe"<<endl;
}
if (gotowe2=1)
{
cout << "2=Gotowe"<<endl;
}
if (gotowe3=1)
{
cout << "3=Gotowe"<<endl;
}
los1 = rand()%10+1;
los2 = rand()%100+1;
los3 = rand()%1000+1;
cout << "1." << los1 <<endl;
cout << "2." << los2 <<endl;
cout << "3." << los3 <<endl;
cout << endl;
cout << "1(1,2,3).PLUS" << endl;
cout << "2(1,2,3).MINUS" << endl;
cout << "->";
cin >> select;
switch(select)
{
case 11:
konto = konto + los1;
cout << "Twoje konto:" << konto << endl;
break;
case 12:
konto = konto + los2;
cout << "Twoje konto:" << konto << endl;
break;
case 13:
konto = konto + los3;
cout << "Twoje konto:" << konto << endl;
break;
case 21:
konto = konto - los1;
cout << "Twoje konto:" << konto << endl;
break;
case 22:
konto = konto - los2;
cout << "Twoje konto:" << konto << endl;
break;
case 23:
konto = konto - los3;
cout << "Twoje konto:" << konto << endl;
break;
}
cout << "Uzbieraj:" << random_number1 << " ," << random_number2 << " ," << random_number3 << endl;
if(konto=los1)
{
gotowe1 = 1;
}
if(konto=los2)
{
gotowe2 = 1;
}
if(konto=los3)
{
gotowe3 = 1;
}
}
return 0;
}
Brakuje jeszcze zliczania prób ale raczej program jest gotowy. Z tym że jak widać linie kodu odpowiedzialne za GOTOWE=1 itd. Już na samym początku działania programu, nie wiem czemu przyjmuje że wszystkie zmienne o nazwie gotowe(1,2,3) są równe 1. Tak być nie powinno. To samo tyczy się funkcji While. O to cu chodzi?