Advertisement
Guest User

Untitled

a guest
May 19th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. #define MIN (-5)
  5. #define MAX (5)
  6. #define NCOL (4)
  7. #define NRIG (4)
  8.  
  9. int main(){
  10. int mat[NRIG][NCOL];
  11.  
  12. int i, j;
  13. char linea[1024];
  14.  
  15. for (i = 0; i < NRIG; i++) {
  16. for (j = 0; j < NCOL; j++) {
  17. do {
  18. fgets(linea, sizeof(linea), stdin);
  19. mat[i][j] = atoi(linea);
  20. } while(mat[i][j] > MAX || mat[i][j] < MIN);
  21. }
  22. }
  23.  
  24. for (i = 0; i < NRIG; i++) {
  25. for (j = 0; j < NCOL; j++) {
  26. printf("%d ", mat[i][j]);
  27. }
  28. putchar('\n');
  29. }
  30.  
  31.  
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement