类似于之前团队天梯赛碰到的进制转化问题??大概就是到了多少就转化一下
这道题特别需要注意的是 如果刚好能整数,年份要-1,因为没有下一年了
(应该是不用改成统一输出的)
#include <iostream> #include <algorithm> #include <stack> #include <queue> #include <vector> #include <cstring> #include <cmath> #include <cstdlib> /* 8 12.pop 123 13.pop 234 14.pop 456 15.pop 567 16.pop 678 17.pop 789 18.pop 890 19.pop 111 */ /* 19 1.pop 111 2.no 222 3.zip 333 4.zotz 444 5.tzec 555 6.xul 666 7.yoxkin 777 8.mol 888 9.chen 999 10.yax 1010 8.zac 1111 7.ceh 1212 4.mac 1313 3.kankin 1414 8.muan 1515 13.pax 1616 2.koyab 1717 18.cumhu 1818 0.uayet 1919 */ /* run this program using the console pauser or add your own getch, system("pause") or input loop */ using namespace std; int main(int argc, char** argv) { int n; scanf("%d",&n); // printf("%d\n",n); int a[5005]; char b[5005][50]; int c[5005]; for(int p=0;p<n;p++) { //pop, no, zip, zotz, tzec, xul, yoxkin, mol, chen, yax, zac, ceh, mac, kankin, muan, pax, koyab, cumhu,uayet int day; char s[105]; int year; scanf("%d.%s%d",&day,s,&year);//天 月 年 // printf("***%d\t%s\t%d\n",day,s,year); int total = 0; // total = day + month* 20 +year*365; 抽象转化为有多少天 if(strcmp(s,"pop")==0)//日期转换 { total = day+1 + (1-1)*20 +year*365; } if(strcmp(s,"no")==0) { total = day+1 + (2-1)*20 + year*365; } if(strcmp(s,"zip")==0) { total = day+1 + (3-1)*20 + year*365; } if(strcmp(s,"zotz")==0) { total = day+1 + (4-1)*20 + year*365; } if(strcmp(s,"tzec")==0) { total = day+1 + (5-1)*20 + year*365; } if(strcmp(s,"xul")==0) { total = day+1 + (6-1)*20 + year*365; } if(strcmp(s,"yoxkin")==0) { total = day+1 + (7-1)*20 + year*365; } if(strcmp(s,"mol")==0) { total = day+1 + (8-1)*20 + year*365; } if(strcmp(s,"chen")==0) { total = day+1 + (9-1)*20 + year*365; } if(strcmp(s,"yax")==0) { total = day+1 + (10-1)*20 + year*365; } if(strcmp(s,"zac")==0) { total = day+1 + (11-1)*20 + year*365; } if(strcmp(s,"ceh")==0) { total = day+1 + (12-1)*20 + year*365; } if(strcmp(s,"mac")==0) { total = day+1 + (13-1)*20 + year*365; } if(strcmp(s,"kankin")==0) { total = day+1 + (14-1)*20 + year*365; } if(strcmp(s,"muan")==0) { total = day+1 + (15-1)*20 + year*365; } if(strcmp(s,"pax")==0) { total = day+1 + (16-1)*20 + year*365; } if(strcmp(s,"koyab")==0) { total = day+1 + (17-1)*20 + year*365; } if(strcmp(s,"cumhu")==0) { total = day+1 + (18-1)*20 + year*365; } if(strcmp(s,"uayet")==0) { total = day+1 + (19-1)*20 + year*365; } // if(strcmp(s,"zac")==0) // { // total = day+1 + (11-1)*20 + year*365; // } //total记录下了有多少天 int yearr = total/260; if(total%260==0) yearr --;//能整除260的话要减一。。。。 没有到下一年 total %=260; // // printf("%d ",yearr); int month = total%13; total %= 20; //现在剩余的就是day了 // total%=20; // printf("%d ",month); // printf("%d\n",total); if(month!=0) { // printf("%d ",month);//imix, ik, akbal, kan, chicchan, cimi, manik, lamat, muluk, ok, chuen, eb, ben, ix, mem, cib, caban, eznab, canac, ahau a[p] = month; } else { // printf("13 "); a[p] = 13; } // printf("%s ") 暂时抽象 if(total==1) { // printf("imix "); strcpy(b[p],"imix"); } if(total==2) { // printf("ik "); strcpy(b[p],"ik"); } if(total==3) { // printf("akbal "); strcpy(b[p],"akbal"); } if(total==4) { // printf("kan "); strcpy(b[p],"kan"); } if(total==5) { // printf("chicchan "); strcpy(b[p],"chicchan"); } if(total==6) { // printf("cimi "); strcpy(b[p],"cimi"); } if(total==7) { // printf("manik "); strcpy(b[p],"manik"); } if(total==8){ // printf("lamat "); strcpy(b[p],"lamat"); } if(total==9){ // printf("muluk "); strcpy(b[p],"muluk"); } if(total==10){ // printf("ok "); strcpy(b[p],"ok"); } if(total==11){ // printf("chuen "); strcpy(b[p],"chuen");} if(total==12){// printf("eb "); strcpy(b[p],"eb");} if(total==13){// printf("ben "); strcpy(b[p],"ben");} if(total==14){// printf("ix "); strcpy(b[p],"ix");} if(total==15){// printf("mem "); strcpy(b[p],"mem");} if(total==16){// printf("cib "); strcpy(b[p],"cib");} if(total==17){// printf("caban "); strcpy(b[p],"caban");} if(total==18){//printf("eznab "); strcpy(b[p],"eznab");} if(total==19){ //printf("canac "); strcpy(b[p],"canac");} if(total==0){ //printf("ahau "); strcpy(b[p],"ahau");} // printf("%d\n",yearr); c[p] = yearr; } printf("%d\n",n); for(int i=0;i<n;i++) { printf("%d %s %d\n",a[i],b[i],c[i]); } //需要改成统一输出 //system("pause"); return 0; }