Advertisement
Guest User

Untitled

a guest
Dec 12th, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. #define MAX 1
  5.  
  6. int main(void)
  7. {
  8. //Deklaration
  9. int iMainZahl;
  10. int iEingabe;
  11. int Counter = 0;
  12. int iCounter=15;
  13.  
  14. iMainZahl = 0;
  15. srand(time(NULL));//init vom Zufallsgenerator
  16.  
  17. iMainZahl = 1 + rand() % 100;
  18. printf("%d", iMainZahl);
  19. do{
  20. do
  21. {
  22. Counter++;
  23. printf("\nRaten(Versuch %d von %d):\t", Counter, iCounter);
  24. scanf_s("%d", &iEingabe);
  25.  
  26. if (iEingabe < iMainZahl) { printf("Die Zahl ist zu NIEDRIG."); }
  27. else if (iEingabe > iMainZahl) { printf("Die Zahl ist zu HOCH."); }
  28. else { printf("Sie haben die Zahl herausgefunden.(%d Versuche)", Counter); iCounter = Counter; Counter = 0; }
  29.  
  30. } while (Counter < iCounter && iEingabe != iMainZahl);
  31. } while (Counter < iCounter);
  32. system("pause");
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement