Skip to content

Instantly share code, notes, and snippets.

@wemakeweb
Last active August 29, 2015 14:02
Show Gist options
  • Save wemakeweb/357340d760c5e5233ff9 to your computer and use it in GitHub Desktop.
Save wemakeweb/357340d760c5e5233ff9 to your computer and use it in GitHub Desktop.
floh.m
int zaehler = 0;
int tip = -1;
int zufallszahl = rand() % 256;
int weiter = 0;
setlocale(LC_ALL, "German");
printf("Das Programm ist ein Zahlen Errater. Sie müssen Tips abgeben und das Programm nähert Sie dann zu der zufälligen Zahl.\n");
do{
printf("\nBitte geben Sie Ihren Tip ein:\n");
scanf("%i", &tip);
if( tip == zufallszahl){
printf("\nSie haben die Zahl erraten!\n");
printf("Sie haben %i Versuche benötigt.\n", zaehler);
weiter = 0;
} else {
zaehler++;
if( tip < zufallszahl ){
printf("\nzu klein!\n");
} else {
printf("\nzu groß!\n");
}
printf("\nMöchten Sie nochmal versuchen? Bitte (J)a oder (N)ein auswählen:\n");
weiter = strcmp(getche(), "j");
}
} while( weiter );
printf("\nProgrammende!\n");
system("PAUSE");
return 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment