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 49 50 51 52 53
| #include<stdio.h>
#include<stdlib.h>
int matrice(int A[50][50],int s)
{
int i,j;
for(i=0;i<s;i++)
{
for(j=0;j<s;j++)
if(A[i][j]==1)
printf("%7d",j);
printf("\n");
}}
main()
{
int A[50][50],s,i,j,pere[50];
do{
printf("donner s: ");
scanf("%d",&s);
}
while(s<=0);
/*la saisie de la matrice adjacente*/
for(i=0;i<s;i++)
{
for(j=0;j<s;j++)
{
do{
printf("donner A[%d][%d]: ",i,j);
scanf("%7d",&A[i][j]);
}
while(A[i][j]<0||A[i][j]>1);
}
}
/*affichage de la matrice*/
printf("matrice donnee:\n");
for(i=0;i<s;i++)
{
for(j=0;j<s;j++)
printf("%7d",A[i][j]);
printf("\n");
}
/*la matrice des successeurs*/
printf("\n la matrice des successeurs est: \n");
matrice(A,s);
printf("l'algorithme de tremaux est: ");
system("pause");
} |
Partager