Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- #include <time.h>
- #define ANTAL_RUNDER 15
- int main(void){
- /* SET RAND-SEED */
- srand(time(NULL));
- /* PROMPT FOR INPUT. N = ANTAL TERNINGER */
- int n;
- printf("indtast antal terninger: ");
- scanf("%d", &n);
- int **array;
- array = malloc(ANTAL_RUNDER * sizeof(int));
- if (array == NULL){
- printf("could not allocate memory");
- return EXIT_FAILURE;
- }
- int i;
- for ( i = 0; i < ANTAL_RUNDER; i++){
- array[i] = malloc(n * sizeof(int));
- if (array[i] == NULL){
- printf("could not allocate memory");
- return EXIT_FAILURE;
- }
- }
- int j;
- for (i = 0; i < ANTAL_RUNDER; i++){
- for ( j = 0; j < n; j++){
- array[i][j] = rand()% 6 + 1;
- printf("%d ", array[i][j]);
- }
- printf("\n");
- }
- /* POINT SYSTEM */
- for ( i = 0; i < n; i++){
- free(array[i]);
- }
- free(array);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement