1.定义一个结构体变量(包括年、月、日),编写程序,要求输入年、月、日,程序能判断该年是否为闰年。(闰年的条件是符合下面两者之一: ①能被4整除,但不能被100整除; ②能被100整除,又能被400整
1.定义一个结构体变量(包括年、月、日),编写程序,要求输入年、月、日,程序能判断该年是否为闰年。(闰年的条件是符合下面两者之一:
①能被4整除,但不能被100整除;
②能被100整除,又能被400整除。
#include <stdio.h>
int main()
{
int i, j, m, n;
struct data
{
int year;
char month;
int day;
}
a;
printf(“please enter year month day.\n”);
scanf("%d %d %d",&a.year,&a.month,&a.day);
i=a.year;
j=i%100;
m=i%4;
n=i%400;
if(m=0 && j!=0)
{
printf(“yes\n”);
}
else if (j=0 && n=0)
{
printf(“yes\n”);
}
else printf(“no\n”);
return 0;
}