1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| #include <stdio.h>
#include <stdlib.h>
#define taille 50;
int **creation(int N,int** matrice)
{
int I,J,i ;
matrice =(int**) malloc( N * sizeof(int*));
if( matrice == NULL )
{
fprintf(stderr,"Allocation impossible");
exit(EXIT_FAILURE);
}
for( i = 0 ; i < N ; i++ )
{
matrice[i] =(int*) calloc (N, sizeof(int));
if( matrice[i] == NULL )
{
fprintf(stderr,"Allocation impossible");
exit(EXIT_FAILURE);
}
}
for (I=0; I<N; I++){
for (J=0; J<N; J++)
{printf("1=> extremite initiale / 0=> extremite finale\n entrer la valeur du noeud [%d][%d]:",I,J);
scanf("%d",matrice[I][J]);}
}
return matrice;
}
main()
{
int** matrix;
int N,I,J;
printf("Entrer le nombre des noeuds: \n");
scanf("%d", &N );
if(N < 50)
matrix=creation(N,matrix);
else
printf("Vous avez depassé le nombre maximum des noeuds accordé");
system("pause");
return 0;
} |
Partager