|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
自己写了个判断是否为闰年的程序
第一次写,和小甲鱼老师的答案不同
#include <stdio.h>
void main()
{
int year;
printf("please input a year:\n");
scanf("%d",&year);
if (year%4==0)
{
printf("that is you want");
if (year%100==0)
{
if (year%400==0)
printf("that is you want");
else
printf("it is not you want");
}
else
{
printf("it is not you want");
}
}
else
{
printf("it is not you want");
}
}
比如我输入2000
它会出现两次that is you want
比如我输入2004
它会出现that is you want 和it is not you want
- #include <stdio.h>
- int main(void)
- {
- int year ;
- printf("please input a year: ") ;
- scanf("%d" , & year) ;
- if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) printf("that is you want") ;
- else printf("it is not you want") ;
- }
复制代码
|
|