41 lines
736 B
C
41 lines
736 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <time.h>
|
|
|
|
int randnumber() {
|
|
return rand() % 99;
|
|
}
|
|
|
|
int maximumnumb() {
|
|
int maxnumber;
|
|
printf("Wie viele Zufallswerte (1..1000): ");
|
|
scanf("%d", &maxnumber);
|
|
return maxnumber;
|
|
}
|
|
|
|
void numberinarry(int *array, int size) {
|
|
int j;
|
|
for (j = 0; j < size; j++) {
|
|
array[j] = randnumber();
|
|
}
|
|
}
|
|
|
|
int main() {
|
|
srand(time(NULL)); // Initialisiere den Zufallszahlengenerator nur einmal
|
|
|
|
int maxnumber = maximumnumb();
|
|
int numbers[maxnumber];
|
|
|
|
numberinarry(numbers, maxnumber);
|
|
|
|
printf("Die Zufallszahlen sind: ");
|
|
int i;
|
|
for (i = 0; i < maxnumber; i++) {
|
|
printf("%d ", numbers[i]);
|
|
}
|
|
printf("\n");
|
|
|
|
return 0;
|
|
}
|
|
|