C语言程序设计,
发布网友
发布时间:2023-11-07 22:01
我来回答
共2个回答
热心网友
时间:2024-12-14 08:52
#include "stdio.h"
struct {
int year;
int month;
int day;
} date;
int main(int argc,char *argv[]){
int i,days=0;//yn;
int daytable[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
printf("Please enter year, month, day(int year>0, 0<onth<13, 0<day<32)...\n");
scanf("%d%d%d",&date.year,&date.month,&date.day);
if(date.year>0)
daytable[2]=(date.year%4==0 && date.year%100 || date.year%400==0) ? 29 : 28;
if(date.year<1 || date.month<1 || date.month>12 || date.day<1 || date.day>daytable[date.month]){
printf("Input error, exit...\n");
return 0;
}
for(i=1;i<date.month;days+=daytable[i++]);
printf("%d-%d-%d is %d day(s) in %d.\n",date.year,date.month,date.day,days+date.day,date.year);
return 0;
}
运行样例:
热心网友
时间:2024-12-14 08:52
潭浩强的C语言的书大概25-30这个样子吧
书店就有得卖啊