爱因斯坦问题

dirtysalt 2005-07-28 10:33:36
爱因斯坦在20世纪初出的这个谜语,题目是这样的:

1、在一条街上,有5座房子,喷了5种颜色。
2、每个房里住着不同国籍的人。
3、每个人喝不同的饮料,抽不同品牌的香烟,养不同的宠物。

提示:

1、英国人住红色房子
2、瑞典人养狗
3、丹麦人喝茶
4、绿色房子在白色房子左面
5、绿色房子主人喝咖啡
6、抽Pall Mall香烟的人养鸟
7、黄色房子主人抽Dunhill香烟
8、住在中间房子的人喝牛奶
9、挪威人住第一间房
10、抽Blends香烟的人住在养猫的人隔壁
11、养马的人住在抽Dunhill香烟的人隔壁
12、抽Blue Master的人喝啤酒
13、德国人抽Prince香烟
14、挪威人住蓝色房子隔壁
15、抽Blends香烟的人有一个喝水的邻居

问题是:谁养鱼?
我写的程序如下,但是运行太慢了,网上由原程序,但是不能在dev-c+下编译。
不知道大家有没有什么好主意???
#include <stdio.h>
enum{english,sweden,danmark,norway,germany}enum_nationality;
enum{red,green,white,yellow,blue}enum_color;
enum{tea,coffee,milk,water,beer}enum_drink;
enum{dog,bird,cat,horse,fish}enum_pet;
enum{pall_mall,dunhill,blends,blue_master,prince}enum_cigratte;
enum{Nationality,Color,Drink,Pet,Cigratte}enum_row;
int a[5][5]={0};
int tmp[5][5]={0};
void print()
{
int j;
for(j=0;j<5;j++)
{
switch(a[0][j])
{
case 0:printf("English");break;
case 1:printf("Sweden");break;
case 2:printf("Danmark");break;
case 3:printf("Norway");break;
case 4:printf("Germany");break;
}
printf("\t");
}
for(j=0;j<5;j++)
{
switch(a[1][j])
{
case 0:printf("Red");break;
case 1:printf("Green");break;
case 2:printf("White");break;
case 3:printf("Yellow");break;
case 4:printf("Blue");break;
}
printf("\t");
}
for(j=0;j<5;j++)
{
switch(a[2][j])
{
case 0:printf("Tea");break;
case 1:printf("Coffee");break;
case 2:printf("Milk");break;
case 3:printf("Water");break;
case 4:printf("Beer");break;
}
printf("\t");
}
for(j=0;j<5;j++)
{
switch(a[3][j])
{
case 0:printf("Dog");break;
case 1:printf("Bird");break;
case 2:printf("Cat");break;
case 3:printf("Horse");break;
case 4:printf("Fish");break;
}
printf("\t");
}
for(j=0;j<5;j++)
{
switch(a[3][j])
{
case 0:printf("Pall Mall");break;
case 1:printf("Dunhill");break;
case 2:printf("Blends");break;
case 3:printf("Blue Master");break;
case 4:printf("Prince");break;
}
printf("\t");
}
printf("\n\n");
}
void cigratte(int count)
{
int j;
if(count==4)
{
for(j=0;j<5;j++)
{
if(tmp[Cigratte][j]==0)
{
a[Cigratte][4]=j;
if(test()==1)
print();
}
}
return ;
}
for(j=0;j<5;j++)
{
if(tmp[4][j]==0)
{
tmp[Cigratte][j]=1;
a[Cigratte][count]=j;
cigratte(count+1);
tmp[Cigratte][j]=0;
}
}
}
void pet(int count)
{
int j;
if(count==4)
{
for(j=0;j<5;j++)
{
if(tmp[Pet][j]==0)
{
a[Pet][4]=j;
cigratte(0);
}
}
return ;
}
for(j=0;j<5;j++)
{
if(tmp[Pet][j]==0)
{
tmp[Pet][j]=1;
a[Pet][count]=j;
pet(count+1);
tmp[Pet][j]=0;
}
}
}
void drink(int count)
{
int j;
if(count==4)
{
for(j=0;j<5;j++)
{
if(tmp[Drink][j]==0)
{
a[Color][4]=j;
pet(0);
}
}
return ;
}
for(j=0;j<5;j++)
{
if(tmp[Color][j]==0)
{
tmp[Color][j]=1;
a[Color][count]=j;
drink(count+1);
tmp[Color][j]=0;
}
}
}
void color(int count)
{
int j;
if(count==4)
{
for(j=0;j<5;j++)
{
if(tmp[Color][j]==0)
{
a[Color][4]=j;
drink(0);
}
}
return ;
}
for(j=0;j<5;j++)
{
if(tmp[Color][j]==0)
{
tmp[Color][j]=1;
a[Color][count]=j;
color(count+1);
tmp[Color][j]=0;
}
}
}
void nationality(int count)
{
int j;
if(count==4)
{
for(j=0;j<5;j++)
{
if(tmp[Nationality][j]==0)
{
a[Nationality][4]=j;
color(0);
}
}
return ;
}
for(j=0;j<5;j++)
{
if(tmp[Nationality][j]==0)
{
tmp[Nationality][j]=1;
a[Nationality][count]=j;
nationality(count+1);
tmp[Nationality][j]=0;
}
}
}
int test()
{
int i,j;
if(a[Drink][2]!=milk)return 0;/*8:住在中间房子的人喝牛奶*/
if(a[Nationality][0]!=norway)return 0;/*9:挪威人住第一间房*/
for(j=0;j<5;j++)
{
if((a[Nationality][j]==english)&&(a[Color][j]!=red)) return 0;/*1:英国人住红色房子*/
if((a[Nationality][j]==sweden)&&(a[Pet][j]!=dog))return 0;/*2:瑞典人养狗*/
if((a[Nationality][j]==danmark)&&(a[Drink][j]!=tea))return 0;/*3:丹麦人喝茶*/
if(a[Color][j]==green)/*4:绿色房子在白色房子左面*/
{
if((j+1)>=5)return 0;
else if(a[Color][j+1]!=white) return 0;
}
if((a[Color][j]==green)&&(a[Drink][j]!=coffee))return 0;/*5:绿色房子主人喝咖啡*/
if((a[Cigratte][j]==pall_mall)&&(a[Pet][j]!=bird))return 0;/*6:抽Pall Mall香烟的人养鸟*/
if((a[Color][j]==yellow)&&(a[Cigratte][j]!=dunhill))return 0;/*7:黄色房子主人抽Dunhill香烟*/
if((a[Cigratte][j]==blue_master)&&(a[Drink][j]!=beer))return 0;/*12:抽Blue Master的人喝啤酒*/
if((a[Nationality][j]==germany)&&(a[Cigratte][j]!=prince))return 0;/*13:德国人抽Prince香烟*/
if(a[Cigratte][j]==blends)/*10:抽Blends香烟的人住在养猫的人隔壁*/
{
if((j==0)&&(a[Pet][j+1]!=cat))return 0;
else if((j==4)&&(a[Pet][j-1]!=cat)) return 0;
else if((a[Pet][j+1]!=cat)||(a[Pet][j-1]!=cat)) return 0;
}
if(a[Pet][j]==horse)/*11:养马的人住在抽Dunhill香烟的人隔壁*/
{
if((j==0)&&(a[Cigratte][j+1]!=dunhill))return 0;
else if((j==4)&&(a[Cigratte][j-1]!=dunhill)) return 0;
else if((a[Cigratte][j+1]!=dunhill)||(a[Cigratte][j-1]!=dunhill)) return 0;
}
if(a[Nationality][j]==norway)/*14:挪威人住蓝色房子隔壁*/
{
if((j==0)&&(a[Color][j+1]!=blue))return 0;
else if((j==4)&&(a[Color][j-1]!=blue)) return 0;
else if((a[Color][j+1]!=blue)||(a[Color][j-1]!=blue)) return 0;
}
if(a[Cigratte][j]==blends)/*15:抽Blends香烟的人有一个喝水的邻居*/
{
if((j==0)&&(a[Drink][j+1]!=water))return 0;
else if((j==4)&&(a[Drink][j-1]!=water)) return 0;
else if((a[Drink][j+1]!=water)||(a[Drink][j-1]!=water)) return 0;
}
}
return 1;
}
int main(int argc, char *argv[])
{
nationality(0);
getchar();
return 0;
}
...全文
289 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
vfl 2005-07-29
  • 打赏
  • 举报
回复
dreee
  • 打赏
  • 举报
回复
不能在论坛里搜索下啊,这问题至少都贴过20次鸟。。

/*
* www.justJF.com / pure UP
*/

/*
[03/12-11:57:35]
当年爱因斯坦称全世界有98%的人做不出来!不过他肯定低估了人类进化的速度
1、在一条街上,有5座房子,喷了5种颜色。
2、每个房里住着不同国籍的人
3、每个人喝不同的饮料,抽不同品牌的香烟,养不同的宠物
问题是:谁养鱼?(所有的对应关系)
提示:
1、英国人住红色房子
2、瑞典人养狗
3、丹麦人喝茶
4、绿色房子在白色房子左面
5、绿色房子主人喝咖啡
6、抽Pall Mall 香烟的人养鸟
7、黄色房子主人抽Dunhill 香烟
8、住在中间房子的人喝牛奶
9、挪威人住第一间房
10、抽Blends香烟的人住在养猫的人隔壁
11、养马的人住抽Dunhill 香烟的人隔壁
12、抽Blue Master的人喝啤酒
13、德国人抽Prince香烟
14、挪威人住蓝色房子隔壁
15、抽Blends香烟的人有一个喝水的邻居
*/

#include <iostream>
#include <cassert>
using namespace std;

enum Color { Red, White, Green, Yellow, Blue };
enum People { Britain, Sweden, Danmark, Norway, Germany };
enum Drink { Tea, Coffee, Milk, Beer, Water };
enum Pet { Fish, Dog, Bird, Cat, Horse };
enum Smoke { PallMall, Dunhill, Blends, BlueMaster, Prince };

struct peopleInfo
{
People ppl;
Color clr;
Drink drk;
Pet pet;
Smoke smk;
};

static peopleInfo info[5];

/* */

inline int findPeo(People p)
{
for(int i=0; i < 5; ++i)
{
if(info[i].ppl == p) return i;
}

assert(false);
return -1;
}

/* */
inline int findClr(Color c)
{
for(int i=0; i < 5; ++i)
{
if(info[i].clr == c) return i;
}

assert(false);
return -1;
}

/* */
inline int findDrk(Drink d)
{
for(int i=0; i < 5; ++i)
{
if(info[i].drk == d) return i;
}

assert(false);
return -1;
}

/* */
inline int findPet(Pet p)
{
for(int i=0; i < 5; ++i)
{
if(info[i].pet == p) return i;
}

assert(false);
return -1;
}

/* */
inline int findSmk(Smoke s)
{
for(int i=0; i < 5; ++i)
{
if(info[i].smk == s) return i;
}

assert(false);
return -1;
}

/* */
inline bool cond1(void)
{ //!
return info[findPeo(Britain)].clr == Red;
}

/* */
inline bool cond2(void)
{ //!
return info[findPeo(Sweden)].pet == Dog;
}

/* */
inline bool cond3(void)
{ //!
return info[findPeo(Danmark)].drk == Tea;
}

/* */
inline bool cond4(void)
{ //!
return findClr(Green) + 1 == findClr(White);
}

/* */
inline bool cond5(void)
{ //!
return info[findClr(Green)].drk == Coffee;
}

/* */
inline bool cond6(void)
{
return info[findSmk(PallMall)].pet == Bird;
}

/* */
inline bool cond7(void)
{
return info[findClr(Yellow)].smk == Dunhill;
}

/* */
inline bool cond8(void)
{ //!
return info[2].drk == Milk;
}

/* */
inline bool cond9(void)
{ //!
return info[0].ppl == Norway;
}

/* */
inline bool cond10(void)
{
int n1=findSmk(Blends), n2=findPet(Cat);
return n1 - n2 == 1 || n1 - n2 == -1;
}

/* */
inline bool cond11(void)
{
int n1=findPet(Horse), n2=findSmk(Dunhill);
return n1 - n2 == 1 || n1 - n2 == -1;
}

/* */
inline bool cond12(void)
{
return info[findSmk(BlueMaster)].drk == Beer;
}

/* */
inline bool cond13(void)
{
return info[findPeo(Germany)].smk == Prince;
}

/* */
inline bool cond14(void)
{ //!
return info[1].clr == Blue;
}

/* */
inline bool cond15(void)
{
int n1=findSmk(Blends), n2=findDrk(Water);
return n1 - n2 == 1 || n1 - n2 == -1;
}

/* */
bool condOther(void)
{ //!( 9 ) ( 1 4 14 ) ( 3 5 8 ) ( 2 )
return cond6() && cond7() && cond10() && cond11() && cond12() && cond13() && cond15();
}

static int indexTab[120][5]; //!5! == 120.

/* */
void makeIndex(void)
{
int nIndex=0;
for(int a=0; a < 5; ++a)
{
for(int b=0; b < 5; ++b)
{
for(int c=0; c < 5; ++c)
{
for(int d=0; d < 5; ++d)
{
for(int e=0; e < 5; ++e)
{
if( a != b && a != c && a != d && a != e &&
b != c && b != d && b != e &&
c != d && c != e &&
d != e)
{
assert(nIndex < 120);
indexTab[nIndex][0]=a;
indexTab[nIndex][1]=b;
indexTab[nIndex][2]=c;
indexTab[nIndex][3]=d;
indexTab[nIndex][4]=e;
++nIndex;
}
}
}
}
}
}

assert(nIndex == 120);
}

const char *szPeo[]={ "Bri", "Swe", "Dan", "Nor", "Ger" };
const char *szClr[]={ "Red", "Wht", "Grn", "Yel", "Blu" };
const char *szDrk[]={ "Tea", "Cof", "Mil", "Bee", "Wat" };
const char *szPet[]={ "Fis", "Dog", "Bir", "Cat", "Hor" };
const char *szSmk[]={ "Pal", "Dun", "Ble", "Blu", "Pri" };

/* */

void showAnser(int a, int b, int c, int d, int e)
{
int i;
cout << "Peo : ";
for(i=0; i < 5; ++i) cout << szPeo[indexTab[a][i]] << ' ';
cout << endl << "Clr : ";
for(i=0; i < 5; ++i) cout << szClr[indexTab[b][i]] << ' ';
cout << endl << "Drk : ";
for(i=0; i < 5; ++i) cout << szDrk[indexTab[c][i]] << ' ';
cout << endl << "Pet : ";
for(i=0; i < 5; ++i) cout << szPet[indexTab[d][i]] << ' ';
cout << endl << "Smk : ";
for(i=0; i < 5; ++i) cout << szSmk[indexTab[e][i]] << ' ';

cout << endl;
}

/* */
int main(void)
{
makeIndex();

int a, b, c, d, e, i;
for(a=0; a < 120; ++a)
{
//cout << "Process a == " << a << endl;
for(i=0; i < 5; ++i) info[i].ppl=(People) indexTab[a][i];
if(!cond9()) continue;
for(b=0; b < 120; ++b)
{
for(i=0; i < 5; ++i) info[i].clr=(Color) indexTab[b][i];
if(!cond14() || !cond1() || !cond4()) continue;
for(c=0; c < 120; ++c)
{
for(i=0; i < 5; ++i) info[i].drk=(Drink) indexTab[c][i];
if(!cond8() || !cond3() || !cond5()) continue;
for(d=0; d < 120; ++d)
{
for(i=0; i < 5; ++i) info[i].pet=(Pet) indexTab[d][i];
if(!cond2()) continue;
for(e=0; e < 120; ++e)
{
for(i=0; i < 5; ++i) info[i].smk=(Smoke) indexTab[e][i];
if(condOther())
{
showAnser(a, b, c, d, e);
}
}
}
}
}
}

return 0;
}


jsjjms 2005-07-29
  • 打赏
  • 举报
回复
值得好好思考。
jixingzhong 2005-07-29
  • 打赏
  • 举报
回复
同意楼上的

用回溯法
conglingkaishi 2005-07-29
  • 打赏
  • 举报
回复
这个问题用穷举要慢吧,应该用回溯法。具体方法怎么实施还是去看算法书去吧。
Smallnetcat 2005-07-29
  • 打赏
  • 举报
回复
还是不要用程序了,自己动笔想一想,比程序快,呵呵
dirtysalt 2005-07-29
  • 打赏
  • 举报
回复
我的搜索能力不行,看了上面的我大概知道要怎么写了,就是将检测条件拆开,在每次递归时分别调用
/*
爱因斯坦在20世纪初出的这个谜语,题目是这样的:

1、在一条街上,有5座房子,喷了5种颜色。
2、每个房里住着不同国籍的人。
3、每个人喝不同的饮料,抽不同品牌的香烟,养不同的宠物。

提示:

1、英国人住红色房子
2、瑞典人养狗
3、丹麦人喝茶
4、绿色房子在白色房子左面
5、绿色房子主人喝咖啡
6、抽Pall Mall香烟的人养鸟
7、黄色房子主人抽Dunhill香烟
8、住在中间房子的人喝牛奶
9、挪威人住第一间房
10、抽Blends香烟的人住在养猫的人隔壁
11、养马的人住在抽Dunhill香烟的人隔壁
12、抽Blue Master的人喝啤酒
13、德国人抽Prince香烟
14、挪威人住蓝色房子隔壁
15、抽Blends香烟的人有一个喝水的邻居

问题是:谁养鱼?*/
#include <stdio.h>
enum{red,green,white,yellow,blue}enum_color;
enum{english,sweden,danmark,norway,germany}enum_nation;
enum{tea,coffee,milk,water,beer}enum_drink;
enum{pall_mall,dunhill,blends,blue_master,prince}enum_cigratte;
enum{dog,bird,cat,horse,fish}enum_pet;
enum{Color,Nation,Drink,Cigratte,Pet}enum_row;
int a[5][5]={0};
int tmp[5][5]={0};
void print()
{
int j;
printf("Answer:\n");
for(j=0;j<5;j++)
{
switch(a[0][j])
{
case 0:printf("Red");break;
case 1:printf("Green");break;
case 2:printf("White");break;
case 3:printf("Yellow");break;
case 4:printf("Blue");break;
}
printf("\t\t");
}
printf("\n");
for(j=0;j<5;j++)
{
switch(a[1][j])
{
case 0:printf("English");break;
case 1:printf("Sweden");break;
case 2:printf("Danmark");break;
case 3:printf("Norway");break;
case 4:printf("Germany");break;
}
printf("\t\t");
}
printf("\n");
for(j=0;j<5;j++)
{
switch(a[2][j])
{
case 0:printf("Tea");break;
case 1:printf("Coffee");break;
case 2:printf("Milk");break;
case 3:printf("Water");break;
case 4:printf("Beer");break;
}
printf("\t\t");
}
printf("\n");
for(j=0;j<5;j++)
{
switch(a[3][j])
{
case 0:printf("Pall Mall");break;
case 1:printf("Dunhill\t");break;
case 2:printf("Blends\t");break;
case 3:printf("Blue Master");break;
case 4:printf("Prince\t");break;
}
printf("\t");
}
printf("\n");
for(j=0;j<5;j++)
{
switch(a[4][j])
{
case 0:printf("Dog");break;
case 1:printf("Bird");break;
case 2:printf("Cat");break;
case 3:printf("Horse");break;
case 4:printf("Fish");break;
}
printf("\t\t");
}
printf("\n\n");
}
void pet(int count)
{
int j;
if(count==4)
{
for(j=0;j<5;j++)
{
if(tmp[Pet][j]==0)
{
a[Pet][4]=j;
if((cond2())&&(cond6())&&(cond10())&&(cond11()))
print();
}
}
return ;
}
for(j=0;j<5;j++)
{
if(tmp[Pet][j]==0)
{
tmp[Pet][j]=1;
a[Pet][count]=j;
pet(count+1);
tmp[Pet][j]=0;
}
}
}
void cigratte(int count)
{
int j;
if(count==4)
{
for(j=0;j<5;j++)
{
if(tmp[Cigratte][j]==0)
{
a[Cigratte][4]=j;
if((cond7())&&(cond12())&&(cond13())&&(cond15()))
pet(0);
}
}
return ;
}
for(j=0;j<5;j++)
{
if(tmp[Cigratte][j]==0)
{
tmp[Cigratte][j]=1;
a[Cigratte][count]=j;
cigratte(count+1);
tmp[Cigratte][j]=0;
}
}
}
void drink(int count)
{
int j;
if(count==4)
{
for(j=0;j<5;j++)
{
if(tmp[Drink][j]==0)
{
a[Drink][4]=j;
if((cond3())&&(cond5())&&(cond8()))
cigratte(0);
}
}
return ;
}
for(j=0;j<5;j++)
{
if(tmp[Drink][j]==0)
{
tmp[Drink][j]=1;
a[Drink][count]=j;
drink(count+1);
tmp[Drink][j]=0;
}
}
}
void nation(int count)
{
int j;
if(count==4)
{
for(j=0;j<5;j++)
{
if(tmp[Nation][j]==0)
{
a[Nation][4]=j;
if((cond1())&&(cond9())&&(cond14()))
drink(0);
}
}
return ;
}
for(j=0;j<5;j++)
{
if(tmp[Nation][j]==0)
{
tmp[Nation][j]=1;
a[Nation][count]=j;
nation(count+1);
tmp[Nation][j]=0;
}
}
}
void color(int count)
{
int j;
if(count==4)
{
for(j=0;j<5;j++)
{
if(tmp[Color][j]==0)
{
a[Color][4]=j;
if(cond4())
nation(0);
}
}
return ;
}
for(j=0;j<5;j++)
{
if(tmp[Color][j]==0)
{
tmp[Color][j]=1;
a[Color][count]=j;
color(count+1);
tmp[Color][j]=0;
}
}
}
int findnation(int i)
{
int j;
for(j=0;j<5;j++)
{
if(a[Nation][j]==i)
return j;
}
}
int findcolor(int i)
{
int j;
for(j=0;j<5;j++)
{
if(a[Color][j]==i)
return j;
}
}
int finddrink(int i)
{
int j;
for(j=0;j<5;j++)
{
if(a[Drink][j]==i)
return j;
}
}
int findpet(int i)
{
int j;
for(j=0;j<5;j++)
{
if(a[Pet][j]==i)
return j;
}
}
int findcigratte(int i)
{
int j;
for(j=0;j<5;j++)
{
if(a[Cigratte][j]==i)
return j;
}
}

int cond1()/*英国人住红色房子*/
{
int j;
j=findnation(english);
if(a[Color][j]==red)
return 1;
else
return 0;
}
int cond2()/*2:瑞典人养狗*/
{
int j;
j=findpet(dog);
if(a[Nation][j]==sweden)
return 1;
else
return 0;
}
int cond3()/*3:丹麦人喝茶*/
{
int j;
j=finddrink(tea);
if(a[Nation][j]==danmark)
return 1;
else
return 0;
}
int cond4()/*4:绿色房子在白色房子左面*/
{
int j;
j=findcolor(green);
if(((j+1)<5)&&(a[Color][j+1]==white))
return 1;
else
return 0;
}
int cond5()/*5:绿色房子主人喝咖啡*/
{
int j;
j=finddrink(coffee);
if(a[Color][j]==green)
return 1;
else
return 0;
}
int cond6()/*6:抽Pall Mall香烟的人养鸟*/
{
int j;
j=findpet(bird);
if(a[Cigratte][j]==pall_mall)
return 1;
else
return 0;
}
int cond7()/*7:黄色房子主人抽Dunhill香烟*/
{
int j;
j=findcigratte(dunhill);
if(a[Color][j]==yellow)
return 1;
else
return 0;
}
int cond8()/*8:住在中间房子的人喝牛奶*/
{
if(a[Drink][2]==milk)
return 1;
else
return 0;
}
int cond9()
{
if(a[Nation][0]==norway)
return 1;/*9:挪威人住第一间房*/
else
return 0;
}
int cond10()/*10:抽Blends香烟的人住在养猫的人隔壁*/
{
int j;
j=findpet(cat);
if((j==0)&&(a[Cigratte][j+1]==blends))return 1;
else if((j==4)&&(a[Cigratte][j-1]==blends)) return 1;
else if((a[Cigratte][j+1]==blends)||(a[Cigratte][j-1]==blends)) return 1;
else
return 0;
}
int cond11()/*11:养马的人住在抽Dunhill香烟的人隔壁*/
{
int j;
j=findpet(horse);
if((j==0)&&(a[Cigratte][j+1]==dunhill))return 1;
else if((j==4)&&(a[Cigratte][j-1]==dunhill)) return 1;
else if((a[Cigratte][j+1]==dunhill)||(a[Cigratte][j-1]==dunhill)) return 1;
else
return 0;
}
int cond12()/*12:抽Blue Master的人喝啤酒*/
{
int j;
j=findcigratte(blue_master);
if(a[Drink][j]==beer)
return 1;
else
return 0;
}
int cond13()/*13:德国人抽Prince香烟*/
{
int j;
j=findcigratte(prince);
if(a[Nation][j]==germany)
return 1;
else
return 0;
}
int cond14()/*14:挪威人住蓝色房子隔壁*/
{
int j;
j=findnation(norway);
if((j==0)&&(a[Color][j+1]==blue))return 1;
else if((j==4)&&(a[Color][j-1]==blue)) return 1;
else if((a[Color][j+1]==blue)||(a[Color][j-1]==blue)) return 1;
else
return 0;
}
int cond15()/*15:抽Blends香烟的人有一个喝水的邻居*/
{
int j;
j=findcigratte(blends);
if((j==0)&&(a[Drink][j+1]==water))return 1;
else if((j==4)&&(a[Drink][j-1]==water)) return 1;
else if((a[Drink][j+1]==water)||(a[Drink][j-1]==water)) return 1;
else
return 0;
}
int main(int argc, char *argv[])
{
color(0);
getchar();
return 0;
}
dirtysalt 2005-07-28
  • 打赏
  • 举报
回复
麻烦大家给个主意??!!谢谢!!!
newbiestar 2005-07-28
  • 打赏
  • 举报
回复
纯穷举……天哪……
dirtysalt 2005-07-28
  • 打赏
  • 举报
回复
上面我自己写的,是不是运行不出结果。
我向interner求助
用baidu搜索"爱因斯坦问题",有个C++的版本源程序,我不能编译它。
所以不知大家有没有什么好办法???thank u!!
(我语言表达能力不行,回去好好学习语文)
LoveYouJustOneDay 2005-07-28
  • 打赏
  • 举报
回复
Compiler: Default compiler
Building Makefile: "C:\DOCUME~1\lll\桌面\Makefile.win"
Executing make...
make.exe -f "C:\DOCUME~1\lll\桌面\Makefile.win" all
gcc.exe main.o -o "Project1.exe" -L"D:/Program Files/Dev-Cpp/lib"

Execution terminated
Compilation successful





我编译通过了
没有错误
连警告都没有

Dev C++ 4.9.9.0编译的(gcc3.3.1)

69,371

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧