Advertisement
Guest User

lab1_esE1

a guest
Mar 17th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.73 KB | None | 0 0
  1. // Federico Vallese , 0000797422 \\
  2.  
  3.  
  4. #include <stdlib.h>
  5. #include <stdio.h>
  6.  
  7.  
  8. int main()
  9. {
  10.     int i=0;
  11.     int B[3][3] = {1,2,3,4,5,6,7,8,9};
  12.     printf("B[0][0] = %d \n", B[0][0]);
  13.     printf("B[1][0] = %d \n", B[1][0]);
  14.     printf("B[0][1] = %d \n", B[0][1]);
  15.    
  16.     int **B2=(int**) malloc(3*sizeof(int*));
  17.     for (i=0; i<3; i++)
  18.     {
  19.         B2[i]=(int*) malloc(3*sizeof(int));
  20.     }
  21.     B2[0][0]=1;
  22.     B2[1][0]=2;
  23.     B2[2][0]=3;
  24.     B2[0][1]=4;
  25.     B2[1][1]=5;
  26.     B2[2][1]=6;
  27.     B2[0][2]=7;
  28.     B2[1][2]=8;
  29.     B2[2][2]=9;
  30.     printf(" Matrice B2: \n");
  31.     printf(" %d \t\t %d \t\t %d \n", B2[0][0],B2[0][1], B2[0][2]);
  32.     printf(" %d \t\t %d \t\t %d \n", B2[1][0],B2[1][1], B2[1][2]);
  33.     printf(" %d \t\t %d \t\t %d \n", B2[2][0],B2[2][1], B2[2][2]);
  34.  
  35.  
  36.     return(0);
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement