Vielen Dank für eure Hilfe.
Ich weiß jetzt wo meine Fehler lagen.
Ich habe jetzt das hier:
Code:
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
cout << "Hallo! "; //Begrüßung Anfang
cout << "Ich will mit dir ein Spiel spielen." << endl;
cout << "Ich denke mir eine Zahl zwischen 1 und 10. " << endl;
cout << "Du musst herauszufinden, welche Zahl ich mir gedacht habe." << endl;
cout << "Los geht's! Du hast 11 Versuche! *grins*" << endl; //Begrüßung Ende
cout << "" << endl; //Leere Zeile
int gesucht = 7;
int zahl;
cout << "Welche Zahl habe ich mir gedacht? ";
bool gefunden = false;
while (! gefunden) {
cin >> zahl;
if (zahl == gesucht) {
gefunden = true;
cout << "" << endl;
cout << "Richtig!" << endl;
cout << "" << endl;
system("PAUSE"); //schließen
return EXIT_SUCCESS;
}
else {
cout << "" << endl;
cout << "Leider falsch!" << endl << "Versuch' es nochmal: ";
}
}
}
Aber irgendwie schaffe ich nicht, dass die gesuchte Zahl zufällig zugewiesen wird.
Ich habe versucht diesen Code hinzuzufügen, aber dann spuckt der Kompiler einen Fehler aus.
Code:
int gesucht = 7;
int zahl;
Random rnd = new Random();
int gesucht = rnd->Next (1, 10);
Der Fehler:
Zitat:
In function `int main(int, char**)':
`Random' was not declared in this scope
expected `;' before "rnd"
redeclaration of `int gesucht'
`int gesucht' previously declared here
`rnd' was not declared in this scope
|
mfg
Underkane