Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

有什么数据,在为难我的程序呢?

Posted by 165646516 at 2006-11-10 21:07:12 on Problem 1008
#include <stdio.h>
int main()
{
  int i,j,n,h_day,h_month,h_year,s,k,t,total,z,round,t_month,t_day,t_year;
  char h[20]={'\0'},temp;
   scanf("%d",&n);
   getchar();
   printf("%d\n",n);
   for(i=0;i<n;i++)
  {
    for(j=0;j<20;j++)
    {
       h[j]='\0';
    }
    gets(h);
    if(h[1]=='.')                              //--------------begin to change the tyoe
      {
        h_day=h[0]-48+1;
        s=3;
      }
    else if(h[2]=='.')
      {
        h_day=10+h[1]-48+1;
        s=4;
      }

    if(h[s]=='n')
    {h_month=3;  s=s+2;}
    else if(h[s]=='t')
    {h_month=5;  s=s+4;}
    else if(h[s]=='x')
    {h_month=6;  s=s+3;}
    else if(h[s]=='u')
    {h_month=19; s=s+5;}
    else if(h[s]=='p')
    {
       s++;
       if(h[s]=='o') {h_month=1;s=s+2;}
       else  { h_month=16;s=s+2; }
    }
    else if(h[s]=='k')
    {
       s++;
       if(h[s]=='o') {h_month=17;s=s+4;}
       else  {h_month=14;s=s+5;}
    }
    else if(h[s]=='y')
    {
       s++;
       if(h[s]=='o') {h_month=7;s=s+5;}
       else  {h_month=10;s=s+2; }
    }
    else if(h[s]=='c')
    {
       s++;
       if(h[s]=='u') {h_month=18;s=s+4;}
       else if(h[s]=='h')  {h_month=9;s=s+3;}
       else {h_month=12;s=s+2;}
    }
    else if(h[s]=='m')
    {
       s++;
       if(h[s]=='o') {h_month=8;s=s+2;}
       else if(h[s]=='a')  {h_month=13;s=s+2;}
       else {h_month=15;s=s+3;}
    }
    else if(h[s]=='z')
    {
       s++;
       if(h[s]=='a') {h_month=11;s=s+2;}
       else if(h[s]=='i')  {h_month=3;s=s+2;}
       else {h_month=4;s=s+3;}
    }
    s++;
    temp=h[s];
    k=0;
    while(temp!='\0')
    {
       k++;
       temp=h[s+k];
    }
    t=1;
    h_year=0;
    for(j=1;j<=k;j++)
    {
      h_year=h_year+(h[s+k-j]-48)*t;
      t*=10;
    }                                       //-------------------------finish  changing the tyoe
    
    round=h_year/52;
    h_year=h_year%52;                      //--------------------------start to culculate
    if(h_month<19)
     total=h_year*365+(h_month-1)*20+h_day;
    else
     total=h_year*365+360+h_day;

    if(h_year*365%260!=0)
    t_year=round*73+(h_year*365/260+1);
    else
    t_year=round*73+(h_year*365/260);

    t_month=total%20;
    t_day=total%13;
    if(t_day==0) t_day=13;
    
    printf("%d ",t_day);
    switch(t_month)
    {
       case 1:printf("imix ");break;
       case 2:printf("ik ");break;
       case 3:printf("akbal ");break;
       case 4:printf("kan ");break;
       case 5:printf("chicchan ");break;
       case 6:printf("cimi ");break;
       case 7:printf("manik ");break;
       case 8:printf("lamat ");break;
       case 9:printf("muluk ");break;
       case 10:printf("ok ");break;
       case 11:printf("chuen ");break;
       case 12:printf("eb ");break;
       case 13:printf("ben ");break;
       case 14:printf("ix ");break;
       case 15:printf("mem ");break;
       case 16:printf("cib ");break;
       case 17:printf("caban ");break;
       case 18:printf("eznab ");break;
       case 19:printf("canac ");break;
       case 0:printf("ahau ");break;
    }
    printf("%d\n",t_year);
  }
  return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator