运行 提交 总是 wrong answer ,我也不知道哪里错了。隐隐感觉日期换算倒来倒去的,可能有错。。
运行编译无措,但是结果有错。。
未完待续。。。
#include<stdio.h>//start at 2014/08/24 20 :03 #include<string.h> #define ISLEAPYEAR(x) x%4 == 0 && x%100 != 0 || x% 400== 0 ? 1 : 0 int dayOfMonth[13][2]={ 0,0, 31,31, 28,29, 31,31, 30,30, 31,31, 30,30, 31,31, 31,31, 30,30, 31,31, 30,30, 31,31 }; struct Date{ int Day; int Month; int Year; void nextDay() { Day++; if( Day > dayOfMonth[Month][ISLEAPYEAR(Year)] ){ Day=1; Month++; if( Month > 12){ Month = 1; Year++; } } } }; int buf[3001][13][32]; char monthName[13][20]={ " ", "January", "February", "March", "April", "May", "June", "July", "August", "September", "November", "December" }; char weekName[7][20]={ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; int main(){ Date tmp; tmp.Day = 1; tmp.Month = 1; tmp.Year = 0; int cnt = 0; while( tmp.Year != 3001 ){ buf[tmp.Year][tmp.Month][tmp.Day] = cnt; tmp.nextDay(); cnt++; } int d,m,y; char s[20]; while( scanf("%d%s%d", &d, s, &y) != EOF ) //这里输入字符串 %s 开始写成s 了 太大意啦!!! { for( m=1; m<13; m++) { if( strcmp(s , monthName[m]) ==0 ) {//注意这里要用字符串比较函数~!! break; } } int days = buf[y][m][d] - buf[2012][7][16];//计算与今天日期的时间间隔 days += 1;// 今天是星期日,对应数组下标0,所以加0 。 puts(weekName[ (days%7+7)%7 ]);//不知道为什么结果是错误的。暂时用这个错误的公式 往后递推了一下下。 } return 0; }