c语言爱因斯坦编程问题,爱因斯坦难题的c语言程序设计(C language programming for Einstein's difficult problems).doc...

爱因斯坦难题的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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值