Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.95 KB | None | 0 0
  1. #include <stdio.h>
  2. #define N 12
  3. #define R 3
  4. #define C 3
  5. //Scrivere una funzione che stampi un vettore
  6.  
  7. void stampaVettore(int array[], int num);
  8. void stampaMatrice(int matrix[R][C]);
  9.  
  10. //Scrivere funzione che stampi matrice utilizzando quella del vettore
  11.  
  12. int main() {
  13.     //non serve il pointer in sto caso
  14.     int array[N] = {1,2,3,4,5,6,7,8,9,10, 11, 12};
  15.  
  16.     int matrix[R][C] = {{1,5,6},
  17.                         {1,4,1},
  18.                         {5,2,1}
  19.                         };
  20.     int i,j;
  21.    // stampaVettore(array, N);
  22.     printf ("\n");
  23.  
  24. /*    for (i=0; i < C; i++){
  25.         for (j=0; j < R; j++){
  26.             printf ("%d",matrix[i][j]);
  27.         }
  28.         printf ("\n");
  29.     }
  30. */
  31.     stampaMatrice(matrix);
  32.  
  33.  
  34. }
  35.  
  36. void stampaVettore(int array[],int num){
  37.  
  38.     int i;
  39.  
  40.     for (i=0; i < num; i++){
  41.         printf ("%d ", array[i]);
  42.     }
  43.  
  44. }
  45. void stampaMatrice(int matrix[R][C]) {
  46.  
  47.     stampaVettore(matrix,R);
  48.    
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement