View Code of Problem 81

#include <stdio.h>
int main(){
  typedef struct{
    int year;
    int month;
    int day;
  }Date;
  Date d;
  int temp;
  scanf("%d%d%d",&d.year,&d.month,&d.day);
  if(d.year%400==0||(d.year%4==0&&d.year%100!=0))
      temp=29;
    else
      temp=28;
  switch(d.month){
    case 1:printf("%d",d.day);break;
    case 2:printf("%d",d.day+31);break;
    case 3:printf("%d",d.day+31+temp);break;
    case 4:printf("%d",d.day+31+temp+31);break;
    case 5:printf("%d",d.day+31+temp+31+30);break;
    case 6:printf("%d",d.day+31+temp+31+30+31);break;
    case 7:printf("%d",d.day+31+temp+31+30+31+30);break;
    case 8:printf("%d",d.day+31+temp+31+30+31+30+31);break;
    case 9:printf("%d",d.day)+31+temp+31+30+31+30+31+31;break;
    case 10:printf("%d",d.day+31+temp+31+30+31+30+31+31+30);break;
    case 11:printf("%d",d.day+31+temp+31+30+31+30+31+31+30+31);break;
    case 12:printf("%d",d.day+31+temp+31+30+31+30+31+31+30+31+30);break;
  }
  
  
  
  
  
  return 0;
}

Double click to view unformatted code.


Back to problem 81