Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  my
Language: C/C++
Code:
#include<stdio.h>
int main(){
    int i,j,num,numm;
    int result,year;
    int month1,date1;
    int std_brth_yr[3];
    int form_date[3];
    int day,month,leaf_year,st;
    int lfyr=0;
    for(i=0;i<3;i++){
    scanf("%d",&form_date[i]);
        }
    scanf("%d",&num);
    numm=num;
    int r[num];
    for(i=0;i<num;i++){
        for(j=0;j<3;j++){
            scanf("%d",&std_brth_yr[j]);
        }
        leaf_year = form_date[0]-std_brth_yr[0];
        st=std_brth_yr[0];
        
        std_brth_yr[0]++;
        
        leaf_year-=1;
        year=leaf_year;
      
       
        while(leaf_year--){
            
            if(std_brth_yr[0]%400==0){
                lfyr++;
                std_brth_yr[0]++;
                
            }
            else if( std_brth_yr[0]%100==0 ){
               
                std_brth_yr[0]++;
                
            }
            
                else if( std_brth_yr[0]%4==0 ){
                    lfyr++;
                    std_brth_yr[0]++;
                
                }
                else{
               
                    
                    std_brth_yr[0]++;
               
                    
                }
           
            }
            if(st%400==0){
                if(std_brth_yr[1] <= 5){
                    month=5-std_brth_yr[i];
                    day= (month+1) * 31;
                    day = day - std_brth_yr[2];
                    day+=7*30;
                    day++;
                    }
                    
                       else if(std_brth_yr[1] <=11 ){
                            month=12-std_brth_yr[1];
                            day= (month+1)*30;
                            day= day -std_brth_yr[2];
                            day++;
                            }
                    
                            else{
                                month = 12-std_brth_yr[1];
                                day=(month+1)*30;
                                day = day-std_brth_yr[2];
                            }
                        }
        else if(st%100== 0){
           if(std_brth_yr[1]<=5){
                month = 5-std_brth_yr[1];
                day=(month+1)*31;
                day -= std_brth_yr[2];
                day+=7*30;
            }
            else{
                month = 12- std_brth_yr[1];
                day = (month+1)*30;
                day-= std_brth_yr[2];
            }
        }
        else if(st%4==0){
            if(std_brth_yr[1] <= 5){
                    month=5-std_brth_yr[i];
                    day= (month+1) * 31;
                    day = day - std_brth_yr[2];
                    day+=7*30;
                    day++;
                    }
                    
                       else if(std_brth_yr[1] <=11 ){
                            month=12-std_brth_yr[1];
                            day= (month+1)*30;
                            day= day -std_brth_yr[2];
                            day++;
                            }
                    
                            else{
                                month = 12-std_brth_yr[1];
                                day=(month+1)*30;
                                day = day-std_brth_yr[2];
                
                            }
                        }
        else{
            
            if(std_brth_yr[1]<=5){
                month = 5-std_brth_yr[1];
                day = (month+1)*31;
               
                day-= std_brth_yr[2];
                
                day+=7*30;
            }
            else{
                month = 12- std_brth_yr[1];
                day = (month+1)*30;
                day-= std_brth_yr[2];
            }
        }
       
        
        if(form_date[0]%400==0){
            if(form_date[1]<=5){
                month1= form_date[1]-1;
                date1=month1*30;
                date1+=form_date[2];
            }
            
            else if(form_date[1] > 5 && form_date[1] <=11){
                month1=form_date[1]-5;
                month-=1;
                date1=month1*30;
                date1+=5*31;
                date1+=form_date[2];
            }
            else{
                month1=form_date[1]-5;
                month1-=1;
                date1=month1*30;
                date1+=5*31;
                date1+=form_date[2];
                date1++;
            }
        }
       else if(form_date[0]%100==0){
            if(form_date[1]<=5){
                month1= form_date[1]-1;
                date1=month1*31;
                date1+=form_date[2];
            }
            else{
                 month1=form_date[1]-5;
                month1-=1;
                date1=month1*30;
                date1+=5*31;
                date1+=form_date[2];
               
            }
        }
        else if(form_date[0]%4==0){
            if(form_date[1]<=5){
                month1= form_date[1]-1;
            
                date1=month1*30;
                date1+=form_date[2];
            }
            else if( form_date[1] >5 && form_date[1] <=11){
                month1=form_date[1]-5;
                month1-=1;
                date1=month1*30;
                date1+=5*31;
                date1+=form_date[2];
            }
            else{
                month1=form_date[1]-5;
                month1-=1;
                date1=month1*30;
                date1+=5*31;
                date1+=form_date[2];
                date1++;
            }
        }
        else{
            if(form_date[1]<=5){
                month1= form_date[1]-1;
                date1=month1*31;
                date1+=form_date[2];
            }
            else{
                 month1=form_date[1]-5;
                month1-=1;
                date1=month1*30;
                date1+=5*31;
                date1+=form_date[2];
               
            }
        }
       
        result = day+date1+lfyr;
        result+= year*365;
        r[i]=result;
        lfyr=0;
        
        }
    for(i=0;i<numm;i++){
        printf("%d\n",r[i]);
    }
    return 0;
        }
                    
Comments: