Advertisement
phoenix79194

Lottozahlen

Feb 24th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.48 KB | None | 0 0
  1. // LOTTOTIPPtrefferZahl
  2. #include<stdio.h>
  3. #include<stdlib.h>
  4. #include<time.h>
  5.  
  6. main()
  7. {
  8.     srand(time(NULL));
  9.    
  10.     int i,j,lotto[6],ziehung[6],treffer;
  11.    
  12.     system("chcp 1252");
  13.    
  14.     while(1>0)
  15.     {
  16.         system("cls");
  17.         // LOTTOTIPP ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  18.         for(i=0;i<6;i=i+1)
  19.         {
  20.             lotto[i]=rand()%49+1;
  21.             for(j=0;j<i;j=j+1)
  22.             {
  23.                 if(lotto[j]==lotto[i])
  24.                 {
  25.                     i=i-1;
  26.                     break;
  27.                 }
  28.             }
  29.         }
  30.         printf("Lottotipp:\n");
  31.         for(i=0;i<6;i=i+1) printf("%i ",lotto[i]);
  32.         // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  33.        
  34.         // LOTTOZIEHUNG +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  35.         for(i=0;i<6;i=i+1)
  36.         {
  37.             ziehung[i]=rand()%49+1;
  38.             for(j=0;j<i;j=j+1)
  39.             {
  40.                 if(ziehung[j]==ziehung[i])
  41.                 {
  42.                     i=i-1;
  43.                     break;
  44.                 }
  45.             }
  46.         }
  47.         printf("\n\nLottoziehung:\n");
  48.         for(i=0;i<6;i=i+1) printf("%i ",ziehung[i]);
  49.         // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  50.        
  51.         // TREFFERERMITTLUNG ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  52.         treffer=0;
  53.         for(i=0;i<6;i++)
  54.         {
  55.             for(j=0;j<6;j++)
  56.             {
  57.                 if(lotto[i]==ziehung[j]) treffer++;
  58.             }
  59.         }
  60.         printf("\n\nEs gab %i Treffer.\n\n\n",treffer);
  61.         // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  62.  
  63.         system("pause");
  64.     }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement