mirror of
https://inf-git.fh-rosenheim.de/studavrije7683/cplusplus-training.git
synced 2025-04-20 02:59:55 +00:00
35 lines
648 B
C++
35 lines
648 B
C++
#include <iostream>
|
|
#include <cstdlib>
|
|
#include <ctime>
|
|
|
|
using namespace std;
|
|
|
|
|
|
int main ()
|
|
{
|
|
int zahl, eingabe, versuche=0;
|
|
|
|
srand (time(NULL));
|
|
zahl = rand()%100 + 1; //Zufallszahl zwischen 0 und 99 wird generiert, daher +1, damit die Zahl zwischen 1 und 100 ist
|
|
|
|
do
|
|
{
|
|
cout << "Zahl eingeben: ";
|
|
cin >> eingabe;
|
|
if(eingabe > zahl)
|
|
cout << "Zu gross!" << endl;
|
|
if(eingabe < zahl)
|
|
cout << "Zu klein!" << endl;
|
|
versuche ++;
|
|
}
|
|
while(eingabe != zahl && versuche < 6);
|
|
|
|
if (eingabe == zahl)
|
|
cout << "Erraten!" << endl;
|
|
else
|
|
cout << "Verloren! Die gesuchte Zahl war " << zahl << endl;
|
|
|
|
system("pause");
|
|
return 0;
|
|
}
|