PKU ACM 1008 题,高手看一下,为什么老是wrong answer

#include<iostream>#include<string>usingnamespacestd;intmain(){intn,i,d,y,t,num,j;char... #include <iostream>
#include <string>
using namespace std;

int main()
{
int n,i,d,y,t,num,j;
char x;
char m[8];
char* a[19]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen", "yax", "zac",
"ceh","mac","kankin","muan","pax","koyab","cumhu","uayet"};
char* b[20]={"imix", "ik","akbal", "kan","chicchan","cimi","manik","lamat","muluk",
"ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"};
cin>>n;
cout<<n<<endl;
while(n--)
{
cin>>d>>x>>m>>y;
for(i=0;i<19;i++)
if(strcmp(m,a[i])==0)
num=y*365+i*20+d+1;
y=num/260;
t=num%260;
d=t%13;
j=t%20;
strcpy(m,b[j-1]);
cout<<d<<' '<<m<<' '<<y<<endl;
}
return 0;
}
展开
 我来答
porker2008
2010-04-05 · TA获得超过1.4万个赞
知道大有可为答主
回答量:7066
采纳率:62%
帮助的人:1.1亿
展开全部
特殊情况没有考虑清楚:

#include <string>
using namespace std;

int main()
{
int n,i,d,y,t,num,j;
char x;
char m[8];
char* a[19]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen", "yax", "zac",
"ceh","mac","kankin","muan","pax","koyab","cumhu","uayet"};
char* b[20]={"imix", "ik","akbal", "kan","chicchan","cimi","manik","lamat","muluk",
"ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"};
cin>>n;
cout<<n<<endl;
while(n--)
{
cin>>d>>x>>m>>y;
for(i=0;i<19;i++)
if(strcmp(m,a[i])==0)
num=y*365+i*20+d+1;
y=num/260;
t=num%260;
if(t==0) y--; // 漏了年底的特殊情况
d=t%13;
if(d==0) d = 13; // 新历不能是0开头
j=t%20;
if(j==0) j = 20; // 当j是0的时候, j-1就成-1了.
strcpy(m,b[j-1]);
cout<<d<<' '<<m<<' '<<y<<endl;
}
return 0;
}
意法半导体(中国)投资有限公司
2023-06-12 广告
STM32是ARM Cortex内核单片机和微处理器市场和技术方面的佼佼者,目前提供16大产品线 (F0, G0, F1, F2, F3, G4, F4, F7, H7, MP1, L0, L1, L4, L4+,L5, WB),超过100... 点击进入详情页
本回答由意法半导体(中国)投资有限公司提供
chp19860820
2010-03-30 · TA获得超过921个赞
知道小有建树答主
回答量:750
采纳率:0%
帮助的人:558万
展开全部
把acm网站发布上去吧。。。看一下要求。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式