Advertisement
michael_xgrind

Untitled

Jul 26th, 2014
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.83 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(){
  4.     int i, j, linhas, colunas;
  5.  
  6.     printf("Digite o numero de linhas: ");
  7.     scanf("%d", &linhas);
  8.     printf("Digite o numero de colunas: ");
  9.     scanf("%d", &colunas);
  10.  
  11.     int matriz[linhas][colunas], vetor[linhas*colunas];
  12.  
  13.     for(i=0; i<linhas; i++){
  14.         for(j=0; j<colunas; j++){
  15.             scanf("%d", &matriz[i][j]);
  16.         }
  17.     }
  18.  
  19.     for(j=0; j<linhas; j++){
  20.         vetor[j] = matriz[0][j];
  21.     }
  22.     for(j=linhas; j<linhas*colunas; j++){
  23.         vetor[j] = matriz[0][j];
  24.     }
  25.  
  26.     printf("\nMatriz:\n");
  27.     for(i=0; i<linhas; i++){
  28.         for(j=0; j<colunas; j++){
  29.             printf("%d ", matriz[i][j]);
  30.         }
  31.         printf("\n");
  32.     }
  33.  
  34.     printf("\nVetor:\n");
  35.     for(i=0; i<linhas*colunas; i++)
  36.         printf("%d ", vetor[i]);
  37.  
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement