myGully.com Boerse.SH - BOERSE.AM - BOERSE.IO - BOERSE.IM Boerse.BZ .TO Nachfolger
Zurück   myGully.com > Computer & Technik > Programmierung
Seite neu laden

[C++] Hilfe bei Zahlenraten

Willkommen

myGully

Links

Forum

 
 
 
Themen-Optionen Ansicht
Prev Vorheriger Beitrag   Nächster Beitrag Next
Ungelesen 13.09.09, 11:07   #8
Underkane
Ist öfter hier
 
Benutzerbild von Underkane
 
Registriert seit: Aug 2008
Beiträge: 232
Bedankt: 26
Underkane leckt gerne myGully Deckel in der Kanalisation! | 1630841 Respekt PunkteUnderkane leckt gerne myGully Deckel in der Kanalisation! | 1630841 Respekt PunkteUnderkane leckt gerne myGully Deckel in der Kanalisation! | 1630841 Respekt PunkteUnderkane leckt gerne myGully Deckel in der Kanalisation! | 1630841 Respekt PunkteUnderkane leckt gerne myGully Deckel in der Kanalisation! | 1630841 Respekt PunkteUnderkane leckt gerne myGully Deckel in der Kanalisation! | 1630841 Respekt PunkteUnderkane leckt gerne myGully Deckel in der Kanalisation! | 1630841 Respekt PunkteUnderkane leckt gerne myGully Deckel in der Kanalisation! | 1630841 Respekt PunkteUnderkane leckt gerne myGully Deckel in der Kanalisation! | 1630841 Respekt PunkteUnderkane leckt gerne myGully Deckel in der Kanalisation! | 1630841 Respekt PunkteUnderkane leckt gerne myGully Deckel in der Kanalisation! | 1630841 Respekt Punkte
Standard

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
__________________
Underkane ist offline   Mit Zitat antworten
 


Forumregeln
Du kannst keine neue Themen eröffnen
Du kannst keine Antworten verfassen
Du kannst keine Anhänge posten
Du kannst nicht deine Beiträge editieren

BB code is An
Smileys sind An.
[IMG] Code ist An.
HTML-Code ist Aus.

Gehe zu


Alle Zeitangaben in WEZ +1. Es ist jetzt 15:07 Uhr.


Sitemap

().