SHARE
TWEET

Zahlenraten

GhostTV Dec 3rd, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4.  
  5. int main(void){
  6.     int zzufall = 0;
  7.     int zeing = 0;
  8.     int versuche = 0;
  9.    
  10.     //Zufallszahl generieren
  11.     srand(time());
  12.     zzufall = (rand()%100) + 1;
  13.    
  14.     while(zeing != zzufall)
  15.     {
  16.         printf("Eingabe einer möglichen Zahl: ");
  17.        
  18.         //Eingabe der geratenen Zahl
  19.         scanf("%i",&zeing);
  20.        
  21.         //Zahl zu groß / klein
  22.         if(zeing < zzufall)
  23.         {
  24.             printf("Zahl zu klein\n");
  25.         }
  26.         else if(zeing > zzufall)
  27.         {
  28.             printf("Zahl zu groß\n");
  29.         }
  30.        
  31.         versuche++;
  32.     }
  33.    
  34.     printf("richtig - %i Versuche", versuche);
  35.  
  36.    
  37.     return 0;
  38. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top