You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
867 B
46 lines
867 B
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <time.h>
|
|
|
|
void leistung(int versuch) {
|
|
if (versuch <= 3) {
|
|
printf("Tolle Leistung!");
|
|
}
|
|
else if (versuch <= 7) {
|
|
printf("Sehr durchschnittliche Leistung!");
|
|
}
|
|
else {
|
|
printf("Miese Leistung!");
|
|
}
|
|
}
|
|
|
|
void run_zahlenraten() {
|
|
|
|
srand(time(NULL));
|
|
|
|
int zahl = rand() % 100 + 1;
|
|
|
|
int versuch = 0;
|
|
int i = 0;
|
|
int vermutung;
|
|
|
|
while (i != 1) {
|
|
|
|
printf("Vermutung: ");
|
|
scanf("%d", &vermutung);
|
|
|
|
versuch++;
|
|
|
|
if (vermutung == zahl) {
|
|
printf("Richtig! Du hast die Zahl in %d Versuchen erraten.\n", versuch);
|
|
leistung(versuch);
|
|
break;
|
|
}
|
|
else if (vermutung < zahl) {
|
|
printf("hoeher!\n");
|
|
}
|
|
else {
|
|
printf("niedriger!\n");
|
|
}
|
|
}
|
|
}
|