输入年月日,要求编程求出这一天的前一天的日期?
- 提问者网友:姑娘长的好罪过
- 2021-07-31 06:56
- 五星知识达人网友:老鼠爱大米
- 2021-07-31 07:27
给你个差不多的吧,求出的是今天的日期
#include "stdio.h"
int GetCount(int Year,int Month)
{
switch(Month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12: return 31;
case 4:
case 6:
case 9:
case 11: return 30;
case 2:
if(Year%4==0&&Year/100!=0||Year%400==0)
return 29;
else
return 28;
}
}
int GetResult(int Year,int Month,int Date)
{
int i,s=0;
for(i=1;i<Month;i++)
{
s+=GetCount(Year,i);
}
s+=Date;
return s;
}
void main()
{
int Year,Month,Date,Fate;
printf("please input Year");
printf("\n");
scanf("%d",&Year);
printf("please input Month");
printf("\n");
scanf("%d",&Month);
printf("please input Date");
printf("\n");
scanf("%d",&Date);
Fate=GetResult(Year,Month,Date);
printf("\n");
printf("%d",Fate);
}