Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Dado uma tabela 4x5 elementos. Calcular a Soma de cada linha e a soma de todos
- os elementos:
- O arquivo numeros.txt contém os seguintes dados:
- | Soma
- 1 0 2 -1 3 | 5
- 4 3 2 1 0 | 10
- 1 -2 3 4 5 | 11
- 8 5 1 3 2 | 19
- --------------------
- Total | 45
- */
- #include <stdio.h>
- #define lin 4
- #define col 5
- main() {
- FILE *arq;
- int i,j;
- int matrz[lin][col];
- arq = fopen("valores.txt", "r");
- for (i=0;i<=lin;i++) {
- for (j=0;j<=col;j++) {
- fscanf(arq, "%d", &matrz[i][j]);
- printf("%d ", matrz[i][j]);
- }
- }
- fclose(arq);
- system("Pause");
- }
Add Comment
Please, Sign In to add comment