Advertisement
Guest User

Untitled

a guest
Oct 12th, 2010
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.95 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4.  
  5. int input;
  6.  
  7. int lotterytype(int type){
  8.     switch(type) {
  9.         default:
  10.             break;
  11.         case 5:
  12.             return 90;
  13.             break;
  14.         case 6:
  15.             return 45;
  16.             break;
  17.     }
  18.     return 0;
  19. }
  20.  
  21. int generate(int lotto) {
  22.     int i=0;
  23.     int szamok[input];
  24.     srand ( time(NULL) );
  25.     szamok[0] = rand()  % lotterytype(input) + 1;
  26.     while (i<=input-1) {
  27.         int n=-1;
  28.         int z=i;
  29.         szamok[i] = rand()  % lotterytype(input) + 1;
  30.         /* Dupla elemek szűrése a tömbből */
  31.         while (n<z) {
  32.             if (szamok[n]==szamok[z]) {
  33.                 szamok[z] = rand()  % lotterytype(input) + 1;
  34.                 /*-printf("DUPLA: %d lett volna!\n", szamok[z]);*/
  35.             }
  36.             else {
  37.                 n++;
  38.             }
  39.         }
  40.         printf("%d\n", szamok[i]);
  41.         i++;
  42.     }
  43.     return 0;
  44. }
  45.  
  46. int main() {
  47.     printf("Milyen lottót szeretnél játszani?\n");
  48.     scanf("%d", &input);
  49.     while (input!=5 && input!=6) {
  50.         printf("Csak 5-ös/6-os lottó választható!\n");
  51.         scanf("%d", &input);
  52.     }
  53.     printf("\n");
  54.     generate(lotterytype(input));
  55.     return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement