pku 1008

Source Code

Problem: 1008 User: cug_fish2008
Memory: 336K Time: 0MS
Language: C++ Result: Accepted
  • Source Code
    #include <iostream>
    using namespace std;
    int haabmonth(char y[]);
    char *tt(int x);
    struct Node
    {
    	int day;
    	char month[6];
    	int year;
    	Node *next;
    };
    int main()
    {
    	int n;
    	char ch;
    	Node *hstart,*hpass;
    	hpass=new Node;
    	hstart=hpass;
    	cin>>n;
    	for(int i=0;i<n;i++)
    	{
    		cin>>hpass->day>>ch>>hpass->month>>hpass->year;
    		if(hpass->year>=50000){i--;continue;}
    		hpass->next=new Node;
    		hpass=hpass->next;
    	}
    	int data;
    	int dayn;
    	int tyear;
    	cout<<n<<endl;
    	for(int i=0;i<n;i++)
    	{
    		int sum=hstart->year*105+haabmonth(hstart->month)*20
    			+hstart->day;
    		if(((sum+1)%260)%13==0)data=13;
    		else data=((sum+1)%260)%13;
    		dayn=(sum%260)%20;
    		tyear=hstart->year+sum/260;
    		cout<<data<<" "<<tt(dayn)<<" "<<tyear<<endl;
    		hstart=hstart->next;
    	}
    	return 0;
    }
    int haabmonth(char y[])
    {
    	for(int i=0;i<6;i++)
    	{
    		if(y[i]=='c'){i++;
    			if(y[i]=='e')return 11;
    			else if(y[i]=='h')return 8;
    			else return 17;}
    		else if(y[i]=='k'){i++;
    			if(y[i]=='a')return 13;
    			else return 16;}
    		else if(y[i]=='m'){i++;
    			if(y[i]=='o')return 7;
    			else if(y[i]=='a')return 12;
    			else return 14;}
    		else if(y[i]=='p'){i++;
    			if(y[i]=='o')return 0;
    			else return 15;}
    		else if(y[i]=='t')return 4;
    		else if(y[i]=='u')return 18;
    		else if(y[i]=='x')return 5;
    		else if(y[i]=='y'){i++;
    			if(y[i]=='o')return 6;
    			else return 9;}
    		else if(y[i]=='z'){i++;
    			if(y[i]=='i')return 2;
    			else if(y[i]=='o')return 3;
    			else if(y[i]=='a')return 10;}
    		else if(y[i]=='n')return 1;
    	}
    }
    char *tt(int x)
    {
    		if(x==0)return "imix";
    		else if(x==1)return "ik";
    		else if(x==2)return "akbal";
    		else if(x==3)return "kan";
    		else if(x==4)return "chicchan";
    		else if(x==5)return "cimi";
    		else if(x==6)return "manik";
    		else if(x==7)return "lamat";
    		else if(x==8)return "muluk";
    		else if(x==9)return "ok";
    		else if(x==10)return "chuen";
    		else if(x==11)return "eb";
    		else if(x==12)return "ben";
    		else if(x==13)return "ix";
    		else if(x==14)return "mem";
    		else if(x==15)return "cib";
    		else if(x==16)return "caban";
    		else if(x==17)return "eznab";
    		else if(x==18)return "canac";
    		else if(x==19)return "ahau";
    }
    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值