Bonjour à tous !

Mon problème est de pouvoir traiter au moins un million de tirage actuel avec le programme qui suit,

pour être aussi clair que possible, pouvoir rentrer 1 Million de sequence de 9 tirages à mon programme sans qu'il bug.

En effet, jusqu'ici, il peut traiter 100 000 tirages max, mais une erreur survient quand je veux un tirage de 1M :

Process terminated with status -1073741819

Voici le code :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
 
void tri_insertion(int tab[], int taille)
 
{
 
   int i, j;
 
   for (i = 1; i < taille; ++i) {
 
       int elem = tab[i];
 
       for (j = i; j > 0 && tab[j-1] > elem; j--){
           tab[j] = tab[j-1];
       }
       tab[j] = elem;
 
   }
 
}
 
int rand_a_b(int a, int b){
 
    return rand()%(b-a) +a;
 
}
 
int* init_sans_doublons(int a, int b)
{
    int taille = b-a;
 
    int* resultat=malloc((taille)*sizeof (int));
 
    int i=0;
 
    // On remplit le tableau de manière à ce qu'il soit trié
 
    for(i = 0; i< taille; i++){
 
        resultat[i]=i+a;
 
    }
 
    return resultat;
 
}
 
void melanger(int* tableau, int taille)
{
 
    int i=0;
    int nombre_tire=0;
    int temp=0;
 
    for(i = 0; i < taille; i++){
 
        nombre_tire=rand_a_b(0,taille);
 
        // On échange les contenus des cases i et nombre_tire
 
        temp = tableau[i];
 
        tableau[i] = tableau[nombre_tire];
 
        tableau[nombre_tire]=temp;
 
    }
 
}
 
int main()
{
    int a=0, o=0;
    int b=36;
    int i=0, n=0; //evalue la taille des tableaux
    int comptage = 0;
    int* selection=NULL; // Va contenir le tableau de nombres
    int nombreTirage = 0, k = 0, x = 0;
    int comptageSequence = 0;
    int* nbgen = NULL;
    printf("Tapez 42 pour quitter le logiciel\n");
 
    while(1)
    {
 
 
        printf("\nCombien de tirage voulez vous effectuer ?");
        scanf("%d", &nombreTirage);
 
         if(nombreTirage == 42) //Permet de quitter la console lorsque l'utilisateur tape 42
        {
            return 0;
        }
 
         //////////////////CHOIX DE LA SELECTION DE 12 NUMEROS///////////////////////////
 
        while(b<=a);
 
        selection=init_sans_doublons(a,b);
 
        melanger(selection,b-a);
 
        int tabSelection[12];
 
        printf("\nLa selection est : ");
 
        srand(time(NULL));
 
        for(i=0; i<12; i++) //selection reglée sur 12 spins
        {
            printf("%d ",selection[i]);
            tabSelection[i]=selection[i];
        }
 
        printf("\nAvant le tri selection : ");
 
        for(o = 0; o < 12; o++) printf("%d ", tabSelection[o]);
 
        printf("\n");
 
        tri_insertion(tabSelection, 12);
 
        printf("Apres le tri selection: ");
 
        for(o = 0; o < 12; o++) printf("%d ", tabSelection[o]);
 
        printf("\n");
 
        free(selection); // Ne pas oublier de libérer le tableau
 
 
        ///////////////TIRAGE DU NOMBRE DE TIRAGES////////////////////////////
 
        if (nombreTirage > 0)
        {
 
            nbgen = malloc (nombreTirage*sizeof(int));
            if ( nbgen == NULL )
            {
                perror("Malloc");
                fprintf(stderr,"Allocation impossible \n");
                exit(EXIT_FAILURE);
            }
 
            srand(time(NULL));
            n = nombreTirage;
            int tabNbgen[9];
            free(nbgen);// Libération de mémoire
 
            for (k = 0 ; k < n ; k++)
            {
                printf("Tirage : ");
 
                for (x = 0 ; x < 9 ; x++)
                {
                    nbgen[i]=rand()%36+0;    //entre 0-36
                    printf("%d ", nbgen[i]);
                    comptage++;
                    tabNbgen[x]=nbgen[i];
                }
                comptageSequence++;    
                printf("\nAvant le tri tirage: ");
 
                for(o = 0; o < 9; o++) {
                    printf("%d ", tabNbgen[o]);
                }
 
                printf("\n");
 
                tri_insertion(tabNbgen, 9);
 
                printf("Apres le tri tirage: ");
 
                for(o = 0; o < 9; o++)
                {
                    printf("%d ", tabNbgen[o]);
                }
 
                printf("\n");
            }
 
            printf("\nIl y a eu %d tirages, donc %d sequences de 9 \n", comptage, comptageSequence);
        }
    }
}
J'ai remplacer tous les int par des long pour essayer, mais rien n'y fait !

Merci pour vos messages d'aide par avance.

P1GOU1