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

为什么总是wa,哪位高手帮看下

Posted by zhao999 at 2008-10-22 18:44:26 on Problem 2080
#include<iostream>
using namespace std;
int main()
{
    int n,y,month,day,i,x,j,q;
    while(1)
    {
            cin>>n;
			q=(n+6)%7;
            if(n==-1)
            break;
            n+=1;
            y=n/1461;
            if(n%1461==0)
                   y--;
			if(n%1461!=0)
             i=n%1461;
			else
				i=1461;
		
            if(i<=366)
            {
                     x=i;
                     j=0;
            }
            else if(i<=731)
            {
                 x=i-366;
                 j=1;
                 }
            else if(i<=1096)
            {
                 x=i-731;
                 j=2;
            }
            else
            {
                x=i-1096;
                j=3;
                }
            if(j==0)
            {
                    for(month=1;month<=12;month++)
                    {
                    if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)
                    {
                    if(x>31)
                    x-=31;
                    else
                    break;
                    }
                    if(month==2)
                    if(x>29)
                    x-=29;
                    else
                    break;
                    if(month==4||month==6||month==9||month==11)
                    if(x>30)
                    x-=30;
                    else
                    break;
 
                    }
            }
            else
            {
                for(month=1;month<=12;month++)
                    {
                
                    if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)
                    if(x>31)
                    x-=31;
                    else
                    break;
                    if(month==2)
                    if(x>28)
                    x-=28;
                    else
                    break;
                    if(month==4||month==6||month==9||month==11)
                    if(x>30)
                    x-=30;
                    else
                    break;
                
                }
            }
            day=x;
            cout<<2000+y*4+j<<"-";
            if(month<10)
            cout<<0<<month<<"-";
            else
            cout<<month<<"-";
            if(day<10)
            cout<<0<<day<<" ";
            else
            cout<<day<<" ";
			if(q==0)
				cout<<"Sunday"<<endl;
            if(q==1)
				cout<<"Monday"<<endl;
			if(q==2)
				cout<<"Tuesday"<<endl;
			if(q==3)
				cout<<"Wednesday"<<endl;
            if(q==4)
				cout<<"Thursday"<<endl;
			if(q==5)
				cout<<"Friday"<<endl;
			if(q==6)
				cout<<"Saturday"<<endl;
    }
    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