Guest User

Untitled

a guest
Jun 24th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. /*
  2. Dado uma tabela 4x5 elementos. Calcular a Soma de cada linha e a soma de todos
  3. os elementos:
  4.  
  5. O arquivo numeros.txt contém os seguintes dados:
  6. | Soma
  7. 1 0 2 -1 3 | 5
  8. 4 3 2 1 0 | 10
  9. 1 -2 3 4 5 | 11
  10. 8 5 1 3 2 | 19
  11. --------------------
  12. Total | 45
  13. */
  14. #include <stdio.h>
  15. #define lin 4
  16. #define col 5
  17.  
  18. main() {
  19. FILE *arq;
  20. int i,j;
  21. int matrz[lin][col];
  22.  
  23. arq = fopen("valores.txt", "r");
  24. for (i=0;i<=lin;i++) {
  25. for (j=0;j<=col;j++) {
  26. fscanf(arq, "%d", &matrz[i][j]);
  27. printf("%d ", matrz[i][j]);
  28. }
  29. }
  30.  
  31. fclose(arq);
  32.  
  33.  
  34. system("Pause");
  35. }
Add Comment
Please, Sign In to add comment