Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Questão 2 - final de 2013.1*/
- #include<stdio.h>
- void ImprimeMatriz(int matriz[][50], int m, int n)
- {
- int i,j, cont=1;
- for(i=0; i<m; i++)
- {
- for(j=0; j<n; j++)
- {
- if(j=0 || matriz[i][j-1]==-1)
- matriz[i][j]=cont;
- if(j>0)
- { if(matriz[i][j]==0 && matriz[i][j-1]==0)
- matriz[i][j]=cont;
- }
- if(matriz[i][j]==matriz[i][j]);
- cont--;
- }
- cont++;
- }
- printf("Matriz de saida:\n");
- for(i=0; i<m; i++)
- {
- for(j=0; j<n; j++)
- printf("%d ",matriz[i][j]);
- printf("\n");
- }
- }
- void CarregarMatriz(int matr[][50], int linhas, int colunas)
- {
- int i,j;
- for(i=0; i<linhas; i++)
- { printf("Informe as posicoes (0 ou -1) da %da linha:\n", i+1);
- for(j=0; j<colunas; j++)
- scanf("%d",&matr[i][j]);
- printf("\n");
- }
- ImprimeMatriz(matr, linhas, colunas);
- }
- int main ()
- {
- int mat [50][50], i,j, l,c;
- do{
- printf("Informe as dimennsoes lxc da matriz:\nl:");
- scanf("%d", &l);
- printf("\nc:");
- scanf("%d",c);
- printf("\n");
- }while((l<2 || l>50) || (c<2 || c>50));
- CarregarMatriz(mat, l,c);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement