当前位置:网站首页>[C exercise] input the month and year, and calculate the number of days in the month
[C exercise] input the month and year, and calculate the number of days in the month
2022-07-18 01:40:00 【Domeecky】
example :

int IsLeapYear(int y)
{
if ((y % 4 == 0 && y % 100 != 0) || (y % 400 == 0))
return 1;
return 0;
}
int main()
{
int y = 0;// Receive variables for the year
int m = 0;// Receive variables of the month
int d = 0;
int day[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
printf(" Please enter year 、 month \n");
scanf("%d %d", &y, &m);
d = day[m - 1];// Get the number of days of the input month , Because the array subscript is from 0 Start , So we need to -1
if ((IsLeapYear(y) == 1) && (m == 2))// Determine if it's a leap year
d++;// If it's a leap year 2 month , Count that day +1
printf("%d year %d Monthly :%d God ", y, m, d);
return 0;
}边栏推荐
猜你喜欢

Online variety show was cold: "Aiyou tengmang" couldn't be put away, "shake up B" couldn't win

【C 练习】输入年月,求出月份天数

Redis入门介绍

云小店商城源码修复30套模板支持一键对接各大系统

After writing a paper in 2 hours, why gpt-3 doesn't deserve a name?

【C数据的存储】

STM32 application development practice tutorial: application development of environmental temperature and humidity monitoring

Redis transaction and message subscription Publishing

JMeter 21 day clock in day02

Matlab low-level source code realizes Prewitt edge detection and Sobel, Laplace edge detection (the implementation effect is consistent with Halcon)
随机推荐
Matlab底层源码实现prewitt边缘检测和Sobel,Laplace边缘检测(实现效果与Halcon一致)
字符串相关函数和内存相关函数的实现
Is it safe to open an account online now? What is the reverse repurchase of treasury bonds?
阿同的小心愿
【C 练习】求n的k次方(递归实现)
善良的人都晚熟
Functions of different types of printing machines
Good people are late acquaintances
2021-09-18
【C 练习】打印‘X’图形
Halcon常用图像预处理算子总结
读书的思考
Staff information management system -- program design
Mysql事务
Cao Yuan, a "genius boy", jointly published the nature sub journal
正式发布丨VS Code 1.69
002 descendant selector
C语言实现简单扫雷游戏(二维数组)
【LaTex 中英文样式&加粗】自由选择中英文字体样式,中英文字体粗黑程度设置
进一步提升数字、智能化水准,亚洲狮首次产品焕新售价14.15万起