Guest User

Untitled

a guest
Apr 24th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<time.h>
  3.  
  4. int main() {
  5. int a, b;
  6. printf("Zahlenraten:\n");
  7. fflush(stdout);
  8.  
  9. printf("Positiven Zahlenbereich eingeben: a-b\n");
  10. fflush(stdout);
  11. scanf("%d-%d", &a, &b);
  12. if(a<0 || b<0){
  13. printf("Ungueltige Zahl\n");
  14. fflush(stdout);
  15. return 0;
  16. }else{
  17. printf("Zahlen ok\n");
  18. fflush(stdout);
  19. }
  20.  
  21. srand(time(NULL));
  22. int rz=(rand()%(a-b))+a;
  23. int z=0;
  24. int i=0;
  25.  
  26.  
  27. while(1>0){
  28. i++;
  29. scanf("%d",&z);
  30. if(z < rz) {
  31. printf("Zahl ist groesser\n");
  32. fflush(stdout);
  33. }
  34. else if(z > rz) {
  35. printf("Zahl ist kleiner\n");
  36. fflush(stdout);
  37. }
  38. else {
  39. printf("Zahl erraten\n", a, b);
  40. fflush(stdout);
  41. }
  42. }
  43.  
  44. return 0;
  45. }
Add Comment
Please, Sign In to add comment