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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
#include <stdio.h>
int doublon(int tab2[])
{
int k;
int l;
int tabcopy[10];
int flag2;
int occurence=0;
for(k=0;k<9;k++){
tabcopy[k]=tab2[k];
}
for(k=0;k<9 && occurence<2;k++){
occurence=0;
for(l=0;l<9 && occurence<2;l++){
if(tabcopy[k]==tab2[l])
{
occurence+=1;
}
}
}
if(occurence>=2){
return 1;
}
else{
return 0;
}
}
int main(){
int nb_equ=0;
int compte=0;
int j=0;
double equation;
for(int a=1;a<10;a++)
{
for(int b=1;b<10;b++)
{
for(int c=1;c<10;c++)
{
for(int d=1;d<10;d++)
{
for(int e=1;e<10;e++)
{
for(int f=1;f<10;f++)
{
for(int g=1;g<10;g++)
{
for(int h=1;h<10;h++)
{
for(int i=1;i<10;i++)
{
int tableau[]={a,b,c,d,e,f,g,h,i};
if(doublon(tableau)==0)
{
equation=a+13*b/c+d+12*e-f-11+g*h/i-10;
if(equation==66)
{
for (j = 0 ; j<9 ; j++)
{
printf("%d ", tableau[j]);
}
printf("\n");
nb_equ+=1;
}
}
}
}
}
}
}
}
}
}
}
printf("nombre equation %d\n",nb_equ);
return 0;
} |
Partager