PHP速学视频免费教程(入门到精通)
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
给定的日期格式为日期、月份和年份(整数)。任务是确定该日期是否可行。
有效日期范围应为 1/1/1800 – 31/12/9999,超出这些日期的日期无效。
这些日期不仅包含年份范围,还包含与日历日期相关的所有约束。
约束是 -
如果所有约束都为真,则它是有效日期,否则不是。
Input: y = 2002 d = 29 m = 11 Output: Date is valid Input: y = 2001 d = 29 m = 2 Output: Date is not valid
START In function int isleap(int y) Step 1-> If (y % 4 == 0) && (y % 100 != 0) && (y % 400 == 0) then, Return 1 Step 2-> Else Return 0 In function int datevalid(int d, int m, int y) Step 1-> If y max_yr then, Return 0 Step 2-> If m 12 then, Return 0 Step 3-> If d 31 then, Return 0 Step 4-> If m == 2 then, If isleap(y) then, If d If m == 4 || m == 6 || m == 9 || m == 11 then, If(d Assign and initialize values as y = 2002, d = 29, m = 11 Step 2-> If datevalid(d, m, y) then, Print "Date is valid" Step 3-> Else Print "date is not valid” End main STOP
实时演示
#include <stdio.h> #define max_yr 9999 #define min_yr 1800 //to check the year is leap or not //if the year is a leap year return 1 int isleap(int y) { if((y % 4 == 0) && (y % 100 != 0) && (y % 400 == 0)) return 1; else return 0; } //Function to check the date is valid or not int datevalid(int d, int m, int y) { if(y max_yr) return 0; if(m 12) return 0; if(d 31) return 0; //Now we will check date according to month if( m == 2 ) { if(isleap(y)) { if(d <p>"); else printf("date is not valid</p> <p>"); return 0; }</p></stdio.h>
如果运行上面的代码,它将生成以下输出 -
Date is valid
已抢7213个
抢已抢94860个
抢已抢14828个
抢已抢52089个
抢已抢194766个
抢已抢87280个
抢