| ||||||||||
| 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 | |||||||||
ft 我可不是什么高手,我也是新手上路In Reply To:我更糟糕.从MLE,到RE.真难找错.高手(first)能指点迷津吗?最起码思路是对的吧.谢谢 Posted by:90303109 at 2003-12-27 00:01:32
(*(p+i)).tyea=da/260;
这样不对
(*(p+i)).tyea=(da%260==0?da/260-1:da/260))
(*(p+i)).tday = st % 13;
也不对
(*(p+i)).tday =((st%13)!=0?(st%13):13)
你要考虑 / 正好整除时候
% 正好是0的时候
> #include <stdio.h>
> #include <string.h>
> struct d{
> int tday;
> char tmon[9];
> int tyea;
> }re[100];
> void main(){
> char ha[20][7]={" ","pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin","mol",
> "chen", "yax", "zac", "ceh", "mac", "kankin", "muan", "pax", "koyab", "cumhu", "uayet"};
> char tz[21][9]={" ","imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik",
> "lamat", "muluk", "ok", "chuen", "eb", "ben", "ix", "mem", "cib", "caban",
> "eznab", "canac", "ahau"};
> int i,j,ca;
> int da;
> int st;//what remain after da is divided by 260
> int hda,hye;
> char hmon[9];
> scanf("%d",&ca);
> for(i=0; i<ca; i++){
> scanf("%d. %s %d",&hda, &hmon, &hye);
> //now transform to normal one(totalday)
> for (j=1; j<19; j++){
> if(strcmp(hmon,ha[j])==0){
> break;
> }
> }
> da=365*hye+(j-1)*20+hda+1;
> //now transform to hzo one
> re[i].tyea=da/260;
> st = da%260;
> strcpy(re[i].tmon,tz[st%20]);
> re[i].tday = st % 13;
> }
> printf("%d\n",ca);
> for(i=0; i<ca; i++){
> printf("%d %s %d\n",re[i].tday,re[i].tmon,re[i].tyea);
> }
> }
>
> //another
>
> /*
> #include <stdio.h>
> #include <string.h>
> #include <malloc.h>
> struct d{
> int tday;
> char tmon[9];
> int tyea;
> };
> void main(){
> struct d *p;
> char ha[20][7]={" ","pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin","mol",
> "chen", "yax", "zac", "ceh", "mac", "kankin", "muan", "pax", "koyab", "cumhu", "uayet"};
> char tz[21][9]={" ","imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik",
> "lamat", "muluk", "ok", "chuen", "eb", "ben", "ix", "mem", "cib", "caban",
> "eznab", "canac", "ahau"};
> int i,j,ca;
> int da;
> int st;//what remain after da is divided by 260
> int hda,hye;
> char hmon[9];
> scanf("%d",&ca);
> p=(struct d*)malloc(sizeof(struct d)*ca);
> for(i=0; i<ca; i++){
> scanf("%d. %s %d",&hda, &hmon, &hye);
>
> for (j=1; j<19; j++){
> if(strcmp(hmon,ha[j])==0){
> break;
> }
> }
> da=365*hye+(j-1)*20+hda+1;
>
> (*(p+i)).tyea=da/260;
> st = da%260;
> strcpy((*(p+i)).tmon,tz[st%20]);
> (*(p+i)).tday = st % 13;
> }
> printf("%d\n",ca);
> for(i=0; i<ca; i++){
> printf("%d %s %d\n",(*(p+i)).tday,(*(p+i)).tmon,(*(p+i)).tyea);
> }
> }*/
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator