找词游戏,用C或者C++编程,救命啊!急需!!!!!!!!!!!!!

在美国流行一种找词游戏,要求游戏者从一张填满字符的正方形表中,找出所有的英文单词,这些词可以横着读、竖着读、或者斜着读。为这个游戏设计一个算法。

第1个回答  2011-06-11
#include <iostream>
#include <math.h>
#include <cstdio>
using namespace std;
int smonth(int);
int firstday(int);
int year,month,day,sum(0);
int main()
{
cin>>year>>month>>day;
for(int i=1;i<month;++i)
sum+=smonth(i);
sum+=day;
int first=firstday(year);
cout<<"属于该年的第"<<sum<<"天"<<"星期"<<(first-1+sum%7)<<endl;
system("pause");
return 0;
}
int smonth(int m)
{
switch(m)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:return 31;
case 4:
case 6:
case 9:
case 11:return 30;
case 2:if(((year%4==0&&year%100!=0)||year%400==0))
return 29;
else
return 28;
default:return 0;
}
}
int firstday(int y)
{
double s;
s=floor(year-1+(year-1)/4.0-(year-1)/100.0+(year-1)/400.0+1);
return (int)s%7;
}

匆忙写的格式什么有点乱,你自己改改吧
追问

这是判断闰年的啊?不是我所需要的呢!能再帮个忙吗??

本回答被网友采纳
第2个回答  2011-06-15
思路:
1、先建立一个单词表,最好用hash表设计
2、对每行中的每个单词实施大搜索。
个人认为:还有更好方法。
相似回答