Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Codigo sequencial sem o uso de threads
- //Lucas de Carvalho Rodrigues da Silva, 8624511
- //Paula Silveira Barbosa, 7149412
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- double **MA, *MB, *x, *new_x, J_ERROR, diff, sum;
- int i, j, nt, J_ORDER, J_ROW_TEST, J_ITE_MAX;
- int main(){
- //MA -> matriz A
- //MB -> matriz B
- //J_ORDER -> ordem da matriz
- //J_ROW_TEST -> linha a ser realizada o teste
- //J_ITE_MAX -> numero maximo de iteracores
- //Leitura das entradas:
- scanf("%d", &J_ORDER);
- scanf("%d", &J_ROW_TEST);
- scanf("%lf", &J_ERROR);
- scanf("%d", &J_ITE_MAX);
- //Criacao das matrizes:
- MA = (double**)malloc(J_ORDER*sizeof(double*));
- MB = (double*)malloc(J_ORDER*sizeof(double));
- x = (double*)malloc(J_ORDER*sizeof(double));
- new_x = (double*)malloc(J_ORDER*sizeof(double));
- //Leitura das matrizes:
- for(i=0; i<J_ORDER; i++){
- MA[i] = (double*)malloc(J_ORDER*sizeof(double));
- for(j=0; j<J_ORDER; j++){
- scanf("%lf", &MA[i][j]);
- }
- }
- for(i=0; i<J_ORDER; i++){
- scanf("%lf", &MB[i]);
- x[i] = MB[i];
- }
- //Fim da leitura das matrizes
- //Faz a desalocacao de memoria:
- for(i=0; i<J_ORDER; i++){
- free(MA[i]);
- }
- free(MA);
- free(MB);
- free(x);
- free(new_x);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement