Advertisement
argentinapb

Untitled

Mar 19th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include <stdio.h>
  2. ler(int mat[100][100]) {
  3. int x, linha = 0, coluna = 0, numeroColunas;
  4.  
  5. while (scanf("%d", & x), x != -2) {
  6. if (x != -1) {
  7. mat[linha][coluna] = x;
  8. coluna++;
  9. } else {
  10. if (linha == 0) {
  11. numeroColunas = coluna;
  12. linha++;
  13. coluna = 0;
  14. } else {
  15. if (numeroColunas != coluna) {
  16. printf("As linhas devem ter o mesmo numero de colunas\n");
  17. return;
  18. } else {
  19. linha++;
  20. coluna = 0;
  21. }
  22. }
  23. }
  24. }
  25. printf("%d linhas, %d colunas", linha++, coluna);
  26. }
  27.  
  28. int main() {
  29. int mat[100][100];
  30. ler(mat);
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement