如何使用C语言找到a年?
年是包括366天的一年。每四年,我们将经历leap年。
我们将执行的逻辑是查找用户通过控制台获得的给定年份是否是飞跃的-
if (( year%400 == 0)|| (( year%4 == 0 ) &&( year%100 != 0)))
如果满足此条件,则给定年份为a年。否则不是。
示例
以下是在If条件的帮助下检查leap年的C程序-
#include <stdio.h>
int main(){
int year;
printf("Enter any year you wish \n ");
scanf(" %d ", &year);
if (( year%400 == 0)|| (( year%4 == 0 ) &&( year%100 != 0)))
printf("\n %d is a Leap Year. \n", year);
else
printf("\n %d is not the Leap Year. \n", year);
return 0;
}输出结果执行以上程序后,将产生以下结果-
Enter any year you wish 2045 2045 is not the Leap Year.
热门推荐
10 财运虎年祝福语简短语
11 单亲爸爸春节祝福语简短
12 狗狗上厕所训练
13 植物种植祝福语简短
14 翻译考试祝福语朋友简短
15 个人周年庆简短祝福语
16 狗狗怎么训练
17 分别祝福语简短搞笑英文
18 生日广州男生祝福语简短