| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
1008问题请教,哪位大神看下,为什么一直说结果错误。谢谢谢谢#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct calen
{
int day;
char mon[7];
int year;
};
int main()
{
char t[20][10] = {"imix", "ik","akbal","kan","chicchan","cimi","manik","lamat","muluk","ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"};
char s[19][10] = { "pop","no","zip","zotz","tzec","xul","yoxkin", "mol","chen","yax","zac","ceh","mac","kankin" ,"muan" , "pax","koyab","cumhu","uayet" };
int n, i, sum, m,m1,y1,y2,d1,j;
char c;
struct calen * ca;
scanf("%d",&n);
for (i = 0; i < n; i++)
{
ca = (struct calen*)malloc(n * sizeof(struct calen));
}
for (i = 0; i < n; i++)
{
scanf("%d%c %s %d",&ca[i].day,&c,&ca[i].mon,&ca[i].year);
}
printf("\n%d\n",n);
for (i = 0; i < n; i++)
{
for (j = 0; i < 19; j++)
{
if (!strcmp(ca[i].mon,s[j]))
{
m = j + 1;
break;
printf("sdsagf\n");
printf("%d\n",m);
}
}
sum = ca[i].year * 365 + (m-1)* 20 + ca[i].day + 1;
y1 = sum /260;
y2 = sum % 260;
m1 = sum%20;
if (m1 == 0)
m1 = m1 + 20;
d1 = sum%13;
if (d1 == 0)
d1 = d1 + 13;
if (y2 == 0 & sum>0)
{
y1 -= 1;;
d1 = 13;
m1 = 20;
}
printf("%d\t%s\t%d\n",d1,t[m1-1],y1);
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator