Advertisement
michael_xgrind

Untitled

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