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 seaeagle at 2005-08-20 19:23:05 on Problem 2080
/*Calendar*/
#include <stdio.h>
int main()
{
 long y,d,days,yearday,m[13],i;
m[1]=31;m[2]=29;m[3]=31;m[4]=30;m[5]=31;m[6]=30;
m[7]=31;m[8]=31;m[9]=30;m[10]=31;m[11]=30;m[12]=31;
  scanf("%ld",&days); 
 while(days!=-1)
 {
  y=2000;
  m[2]=29;
  yearday=366;
  d=days;
  while(days>=yearday)
   {
    days=days-yearday;
    y++;
    if((y%100!=0)&&(y%4==0)||(y%400==0))
     {m[2]=29;
      yearday=366;      
     }
    else
     {m[2]=28;
      yearday=365;
     }
   }
  printf("%ld-",y);
  for(i=1;i<=12;i++)
   {
    if(days>=m[i])
     days=days-m[i];
    else
     break;
   }
  if(i<10) 
   printf("0");
  printf("%ld-",i);
  if(days<10)
   printf("0");
  printf("%ld ",days+1);
  switch (d%7)
  {
   case 0: printf("Saturday\n"); break;
   case 1: printf("Sunday\n"); break;
   case 2: printf("Monday\n"); break;
   case 3: printf("Tuesday\n"); break;
   case 4: printf("Wednesday\n"); break;
   case 5: printf("Thursday\n"); break;
   case 6: printf("Friday\n"); break;
  }
  
    scanf("%ld",&days); 
 }
   
 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