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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
| #include <stdio.h>
int recherch (int x , int t1[8], int t3[8])
{
int n,y,i,a,s ;
n=6 ;
a=0;
while ((n>0) || (a==0))
{
if (t3[n]==1)
{
i=n+1;
a=1;
}
else n-- ;
}
y=1;
while ((i<7) || (y!=2))
{
if (x==t1[i])
{
y=2;
s=1;
}
else {i++; s=0;
}
}
return s;
}
int main()
{
int t1[8]={9,5,7,4,1,7,6,4} ;
int t2[8]={9,5,4,7,7,5,4,3} ;
int t3[8]={1,0,0,0,0,0,0,0} ;
int i,y,j,x;
i=1;
j=1;
x=1;
while (i<=7)
{
if (t1[i]==t2[j] )
{
t3[x]=1 ;
i++;
j++;
x++;
}
else if (recherch(t2[j],t1,t3)==1)
{
t3[x]=2 ;
i++;
j++;
x++;
}
else
i++;
j++;
x++;
}
return 0;
for (y=0;y<8;y++)
{
printf("%i",t3[y]);
}
} |