当前位置:网站首页>【C 练习】输入年月,求出月份天数
【C 练习】输入年月,求出月份天数
2022-07-15 10:34:00 【Domeecky】
例:

int IsLeapYear(int y)
{
if ((y % 4 == 0 && y % 100 != 0) || (y % 400 == 0))
return 1;
return 0;
}
int main()
{
int y = 0;//接收年的变量
int m = 0;//接收月的变量
int d = 0;
int day[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
printf("请输入年、月\n");
scanf("%d %d", &y, &m);
d = day[m - 1];//取出输入月份的天数,因为数组下标是从0开始,所以需要-1
if ((IsLeapYear(y) == 1) && (m == 2))//判断是否为闰年
d++;//如果是闰年的2月份,那天数要+1
printf("%d年%d月有:%d天", y, m, d);
return 0;
}边栏推荐
- 正式发布丨VS Code 1.69
- 结构体相关类型解析
- Matlab底层源码实现prewitt边缘检测和Sobel,Laplace边缘检测(实现效果与Halcon一致)
- STM32应用开发实践教程:环境参数持久化存储的应用开发
- 智能指针的说明与简单实现
- MFC宠物商店信息管理系统
- QT | vs2017 + qt5.14.2 environment construction
- From March to June, after summary, more than 200 pages of true question notes and detailed explanations (including core test sites and 6 major factories)
- 职员信息管理系统--程序设计
- Network security (2)
猜你喜欢

【HCIA】数通网络基础

让AI像婴儿一样思考!DeepMind「柏拉图」模型登Nature子刊

Incremental abstraction in distributed probabilistic slam graph

Realizing Halcon scale with MATLAB low-level source code_ image_ Range (can be used for background segmentation)

Matlab底层源码实现图像动态二值化

Large end byte order and small end byte order

Software testing? Monthly salary 20K +? I can't automate the test. It's really hard for me

Matlab底层源码实现prewitt边缘检测和Sobel,Laplace边缘检测(实现效果与Halcon一致)

Important - Im open source project openim about version management and v2.3.0 release plan

告别徕卡,华为开启全新时代!网友:小米......
随机推荐
Matlab bottom source code realizes image corrosion and expansion operation (consistent with Halcon effect)
Let AI think like a baby! Deepmind "Plato" model published in nature
An OTL power amplifier circuit with a new vest
Summary of Halcon common image preprocessing operators
阿同的小心愿
Matlab bottom source code to realize image dynamic binarization
input仅允许输入英文、中文及其他各种符号文字
Typescript 14 starting from 0: built in tool type
Network security (1)
Common vulnerability types of tcp/ip protocol
Detailed installation steps of mysql5.6 version
Solution of in multi column special query type in laravel
JMeter 21 天打卡 day04
云服务器跟物理机哪个更适合做高防服务器
Excel fast l count the number of red data in all lines [commonly used in teaching]
关于Kubernetes中kubelet的一些笔记
Development practice - reasoning application development experience of shengteng cann
Remove the loading interface of cocoscreator
Online multi line text batch regular replacement add suffix tool
[latex Chinese and English style & Bold] freely choose Chinese and English font styles, and set the bold and black degree of Chinese and English fonts