Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- int input;
- int lotterytype(int type){
- switch(type) {
- default:
- break;
- case 5:
- return 90;
- break;
- case 6:
- return 45;
- break;
- }
- return 0;
- }
- int generate(int lotto) {
- int i=0;
- int szamok[input];
- srand ( time(NULL) );
- szamok[0] = rand() % lotterytype(input) + 1;
- while (i<=input-1) {
- int n=-1;
- int z=i;
- szamok[i] = rand() % lotterytype(input) + 1;
- /* Dupla elemek szűrése a tömbből */
- while (n<z) {
- if (szamok[n]==szamok[z]) {
- szamok[z] = rand() % lotterytype(input) + 1;
- /*-printf("DUPLA: %d lett volna!\n", szamok[z]);*/
- }
- else {
- n++;
- }
- }
- printf("%d\n", szamok[i]);
- i++;
- }
- return 0;
- }
- int main() {
- printf("Milyen lottót szeretnél játszani?\n");
- scanf("%d", &input);
- while (input!=5 && input!=6) {
- printf("Csak 5-ös/6-os lottó választható!\n");
- scanf("%d", &input);
- }
- printf("\n");
- generate(lotterytype(input));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement