输入某年某月某日,判断这一天是这一年的第几天

main()
{
 int year,month,date,i,j,totalDays=0;
 int day[2][13]={
      {0,31,28,31,30,31,30,31,31,30,31,31},
      {31,29,31,30,31,30,31,31,30,31,31}
     };
 printf("enter year:/n");
 scanf("%d",&year);
 if((year%4&&!year%100)||year%400)
  i=0;
 else
  i=1;
 
 do{
  printf("enter month:/n");
  scanf("%d",&month);
 }while(month<=0||month>12);
 
 do{
  printf("enter date:/n");
  scanf("%d",&date);
 }while(date<=0||date>day[i][month]);
 for(j=1;j<month;j++)
 {
  totalDays+=day[i][j];
 }
 totalDays+=date;
 printf("%d-%d-%d is %d's %dth day。/n",year,month,date,year,totalDays);
}
阅读更多

没有更多推荐了,返回首页