提交到北京大学ACM系统上一直出现runtime error,求解!!

#include<stdio.h>#include<string.h>intx(inta,charb[10],intc){inti,sum;chard[19][10]={... #include<stdio.h>
#include<string.h>
int x(int a,char b[10],int c)
{

int i,sum;
char d[19][10]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen","yax","zac","ceh","mac","kankin","muan","pax","koyab","cumhu","uayet"};
if(strcmp(b,d[18])==0)
sum=c*365+18*20+a+1;
else
{
for(i=0;i<18;i++)
if(strcmp(b,d[i])==0)
break;
sum=c*365+i*20+a+1;
}
return sum;
}
int main()
{
char e[20][10]={"imix","ik","akbal","kan","chicchan","cimi","manik","lamat","muluk","ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"};
int n,z,w,k;
int o[100],q[100],r,t;
char s[10],p[100][10];
scanf("%d",&n);
for(z=0;z<n;z++)
{
scanf("%d.%s %d",&r,s,&t);
w=x(r,s,t);
q[z]=w/260;
w=w%260;
o[z]=w%13;
k=w%20;
strcpy(p[z],e[k-1]);
}
printf("%d\n",n);
for(z=0;z<n;z++)
printf("%d %s %d\n",o[z],p[z],q[z]);
return 0;
}
展开
 我来答
Res_TP
2017-11-15 · TA获得超过1544个赞
知道小有建树答主
回答量:587
采纳率:85%
帮助的人:229万
展开全部

兄弟你这个

题目里没有保证输入数据小于100组啊

你这开100的数组存答案肯定不够啊

还有提问居然都不给个题目链接,还是我自己去搜到的

还好多年ACM选手

P.S.没必要存起来在输出

online Judge 的输入输出是两个文件,不是混在一起的

算完一组直接输出就行了

改过的代码:

#include<stdio.h>
#include<string.h>
int x(int a, char b[10], int c)
{

int i, sum;
char d[19][10] = { "pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen","yax","zac","ceh","mac","kankin","muan","pax","koyab","cumhu","uayet" };
if (strcmp(b, d[18]) == 0)
sum = c * 365 + 18 * 20 + a + 1;
else
{
for (i = 0;i<18;i++)
if (strcmp(b, d[i]) == 0)
break;
sum = c * 365 + i * 20 + a + 1;
}
return sum;
}
int main()
{
char e[20][10] = { "imix","ik","akbal","kan","chicchan","cimi","manik","lamat","muluk","ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau" };
int n, z, w, k;
int o[100], q[100], r, t;
char s[10], p[100][10];
scanf("%d", &n);
printf("%d\n", n);
for (z = 0;z<n;z++)
{
scanf("%d.%s %d", &r, s, &t);
w = x(r, s, t);
q[0] = w / 260;
w = w % 260;
o[0] = w % 13;
k = w % 20;
printf("%d %s %d\n", o[0], e[k - 1], q[0]);
}
return 0;
}
追问
大神神神我复制你的程序提交又出现compile error,求帮助-.-
有个要求是这样婶的,我出错可能因为这个吗
(输入中的第一行表示要转化的Haab历日期的数据量。下面的每一行表示一个日期,年数小于5000。)
追答
我看看啊,稍等哈
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

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

类别

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

说明

0/200

提交
取消

辅 助

模 式