Segmentation failure C

Asked

Viewed 10 times

0

I need help with this college job. My matrix cannot pass values above 1000 always from the segmentation error in the program. I have tried gdb but only returned it

Program Received Signal SIGSEGV, Segmentation fault. 0x000055555555528f in main ()

I do not know what the problem of the program so that it cannot assume values above 1000 in the matrix.

#include<stdio.h>

int main(){

        long int numero_pacotes, contagem, limite_carga, peso_pacote[100000], i, j, matriz[100000][100000], maior = 0, pacote_1 = 0, pacote_2 = 0;

        scanf("%li", &numero_pacotes);

        for(contagem = 1; contagem <= numero_pacotes; contagem++){

                scanf("%li", &peso_pacote[contagem]);
        }

        scanf("%li", &limite_carga);

        for(i = 1; i < numero_pacotes; i++){
                for(j = i + 1; j <= numero_pacotes; j++){

                        matriz[i][j] = peso_pacote[i] + peso_pacote[j];

                        if(matriz[i][j] > maior && matriz[i][j] <= limite_carga){

                                maior = matriz[i][j];

                                pacote_1 = i;

                                pacote_2 = j;
                        }
                }
        }

        printf("Pacotes Selecionados: %li, %li.\n", pacote_1, pacote_2);

        return 0;
}

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.