#1259: 我哪裡錯了?


andy3466 (阿尼亞要我下次記得開讀檔)

學校 : 臺北市立成功高級中學
編號 : 4702
來源 : [118.168.221.144]
最後登入時間 :
2015-07-06 10:49:34
d047. 10070 - Leap Year or Not Leap Year and ... -- UVa10070 | From: [61.229.107.112] | 發表日期 : 2009-01-26 19:51

#include<iostream>        
using namespace std;        
char a[10000000];     
int main()        
{        
    
int l,leap=0,add,t=0,ed=0,od=0,hu=0,ku=0;     
while(cin>>a)     
{         
l=strlen(a);     
//判斷閏年      
if(a[l-1]-48==0&&a[l-2]-48==0&&(((a[l-3]-48)+((a[l-4]-48)*10))%4==0)){leap=1;}     
else if(a[l-1]-48!=0||a[l-2]-48!=0)     
                                   {     
                                    add=(a[l-1]-48)+((a[l-2]-48)*10);                                                    
                                    if(add%4==0){leap=1;}                                                    
                                    }                                                     
                                                                                        
                                                                                      
//判斷Huluculu      
if(a[l-1]-48==5||a[l-1]-48==0)     
{     
for(int i=0;i<l;i++)     
{                             
 t=(a[i]-48)+t;                            
 }     
if(t%3==0){hu=1;}                        }     
    
    
    
    
    
    
//判斷bulukulu    
if(a[l-1]-48==5||a[l-1]-48==0)  
{   
for(int i=l-1;0<=i;i=i-2)  
{  
od=od+(a[i]-48);          
}  
for(int i=l-2;0<=i;i=i-2)  
{  
ed=ed+(a[i]-48);            
}   
if(((od-ed)%11)==0){ku=3;}     
}   
    
    
    
//輸出      
 if(leap==1&&ku!=3){cout<<"This is leap year."<<endl;}     
 if(hu==1){cout<<"This is huluculu festival year."<<endl;}      
 if(ku==3&&leap==1){cout<<"This is bulukulu festival year."<<endl;}     
 if(leap==0&&hu==0&&(ku==0||ku==3)){ cout<<"This is an ordinary year."<<endl;}     
 cout<<endl;  
 leap=0;      
 t=0;     
 hu=0;     
 ku=0;  
 ed=0;  
 od=0;       
}     
 system ("pause");        
 return 0;           
    }       
ZeroJudge Forum