Last active
December 16, 2015 11:58
-
-
Save fliiiix/5430862 to your computer and use it in GitHub Desktop.
Do What The Fuck You Want To Public License
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/******************************************************************************* | |
* | |
* | |
* Beschreibung: Diese Programm kann zufällige zahlen Generieren. | |
* | |
* Benötigte Libraries: | |
* - stdlib.h | |
* - stdio.h | |
* - time.h | |
* | |
* Do What the Fuck You Want to Public License | |
*******************************************************************************/ | |
/*** Include Files ***********************************************************/ | |
#include <stdlib.h> /* Funktionsbibliothek: Hilfsfunktionen */ | |
#include <stdio.h> /* Funktionsbibliothek: Standard Ein- Ausgabe */ | |
#include <time.h> /* Funktionsbibliothek: Bibliothek der Zeit*/ | |
/*** Globale Deklarationen und Definitionen **********************************/ | |
void getRandomSeed() | |
{ | |
static char zufall; | |
if(zufall != 1) | |
{ | |
/* inizialisierung random seed: */ | |
srand ( time(NULL) ); | |
zufall = 1; | |
} | |
} | |
int getRandom(int Min, int Max) | |
{ | |
getRandomSeed(); | |
return (rand() % (Max - Min +1) + Min); | |
} | |
int sort(const void *x, const void *y) { | |
return (*(int*)x - *(int*)y); | |
} | |
int genearateLottoZahle(int *GezogeneZahlen) | |
{ | |
int lottoZahlen[45] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, | |
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, | |
31, 32, 33, 34,35,36, 37, 38, 39, 40, 41, 42, 43, 44, | |
45}; | |
int TemporaereZahl = -1; | |
int Random = -1; | |
int i = -1; | |
for(i = 0; i < 6; i++) | |
{ | |
Random = getRandom(1, 45); | |
TemporaereZahl = lottoZahlen[i]; | |
lottoZahlen[i] = lottoZahlen[Random]; | |
lottoZahlen[Random] = TemporaereZahl; | |
} | |
//int GezogeneZahlen[5]; | |
for(i = 0; i < 6; i++) | |
{ | |
GezogeneZahlen[i] = lottoZahlen[i]; | |
} | |
} | |
int main(void) | |
{ | |
int i = -1; | |
int LottoZahlen[6]; | |
genearateLottoZahle(LottoZahlen); | |
qsort(LottoZahlen, 5, sizeof(int), sort); | |
for(i = 0; i < 6; i++) | |
{ | |
printf("%d\n", LottoZahlen[i]); | |
} | |
system("PAUSE"); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment