爱因斯坦难题的c语言程序设计(C language programming for Einstein's difficult problems)
爱因斯坦难题的c语言程序设计(C language programming for Einstein's difficult problems)
The results show that there are seven possible answers, as follows
First kinds of solutions for data interchange for trade data interchange for trade
The topic is:
1, on a street, there are 5 houses, sprayed in 5 colors.
2, each room lives in different nationalities
3. Everyone drinks different drinks, smokes different brands of cigarettes, and raises different pets
Constraint condition:
1, the British live in the red house
2. The Swede raises dogs
3. The Danes drink tea
4. The green house is on the left of the White House
5. The green house owner drinks coffee
6, Pall pumping Mall cigarettes were aviculture
7, yellow house owner smoke, Dunhill cigarettes
8. The man living in the middle house drinks milk
9 Norwegian live in the first room
10 、 people who smoke Blends live next door to those who keep cats
11, horses who live in the Dunhill cigarette smoke next door
12, Blue Master people drink beer
13, Germans smoke Prince cigarettes
14 Norwegian live next door to blue house
15 、 the person who smokes Blends has a neighbor who drinks water
The question is: who raises fish?
#include
Char*COL[]={NULL, "red", "yellow", "green", "blue", "white",};
Char*PAD[]={NULL, "dog", "cat", "fish", "bird", "Ma"};
Char*DRK[]={NULL, "tea", "milk", "coffee", "beer", "water"};
Char*GUO[]={NULL, "Norway", "Britain", "Germany", "Denmark", "Sweden"};
Char*SMK[]={NULL, "Blends", "BlueMaster", "Dunhill", "Pall Mall", "Prince"};
Struct{, char, Guojia, color, pads, drink, smoke,}, aa[5];
Int OK (void)
{
Int, I, j;
For (i=0; i<5; i++)
If (aa[i].guojia==2 and aa[i].color==1) goto next1;
Return 0;
Next1:
For (i=0; i<5; i++)
If (aa[i].guojia==5 and aa[i].pads==1) goto next2;
Return 0;
Next2:
For (i=0; i<5; i++)
If (aa[i].guojia==4 and aa[i].drink==1) goto next3;
Return 0;
Next3:
For (i=0; i<5; i++)
If (aa[i].color==3) goto next3_1;
Return 0;
Next3_1:
For (j=i+1; j<5; j++)
If (aa[j].color==5) goto next4;
Return 0;
Nex