c/c++语言开发共享C语言 判断0年—3000年之间的闰年

#include<stdio.h> int main() { int year,leap=1; printf("ttt判断0~3000之间的闰年n&quot

  #include<stdio.h>  int main()  { int year,leap=1;   printf("ttt判断0~3000之间的闰年n");   printf("请输入0~3000之间的年份n");  flag:   scanf("%d",&year); //输入年份   if(year>0&&year<=3000)      //四年一润,百年不润,四百年再润     {         if(year%4!=0)            leap=0;         else if(year%100!=0)             leap=1;        if(year%400!=0)            leap=0;                              if(leap)//leap为1,是闰年               printf("%d is",year);             else               printf("%d is not",year);               printf(" a leap year.n");             goto flag;      }     else        printf("输入错误,请输入0~3000之间的年份n");           goto flag;   return 0;  }

备注:flag为标签goto flag 转向标签的位置继续运行。

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/c-cdevelopment/606038.html

(0)
上一篇 2021年5月13日
下一篇 2021年5月13日

精彩推荐