C语言日期计算器
2024-09-29 09:09:19
记录下码子
# define _CRT_SECURE_NO_WARNINGS
# include <stdio.h>
# include <stdlib.h> int days(int month)
{
int day;
switch (month)
{
case :
day = ; //1月天数
break;
case :
day = +; //1+2月天数
break;
case :
day = + + ; //1+2+3月天数
break;
case :
day = + + + ;
break;
case :
day = + + + + ;
break;
case :
day = + + + + + ;
break;
case :
day = ++ + + + + ;
break;
case :
day = + + + + + + + ;
break;
case :
day = ++ + + + + + + ;
break;
case :
day =+ + + + + + + + + ;
break;
case :
day = ++ + + + + + + + + ;
break;
case :
day = + + + + + + + + + + + ; //12个月的天数
break;
}
return day;
} int main()
{
int month, day,days1;
int month_2, day_2,days2;
int result;
printf("请输入一个日期\n");
scanf("%d %d", &month, &day); printf("请输入第二个日期\n");
scanf("%d %d", &month_2, &day_2); days1 = days(month) + day; //计算第一个日期的天数
days2 = days(month_2) + day_2; //计算第二个日期的天数
//printf("%d %d", days1, days2); //大的天数减去小的天数
if (days1 > days2)
{
result = days1 - days2;
}
else
{
result = days2 - days1;
}
printf("\n");
printf("%d月%d日和%d月%d日间隔%d天\n", month, day, month_2, day_2,result);
system("pause");
return ;
}
运行结果:
最新文章
- tomcat集群实例重复执行
- [HTML5]HTML语义(Semantics)
- 2.每人自己建立一个HelloWorld项目,练习使用git的add/commit/push/pull/fetch/clone等基本命令。比较项目的新旧版本的差别。答题人:张立鹏
- linux中使用软链接时出现 too many levels of symbolic links
- CSS_网站配色参考方案
- MES项目中出现的一个事务嵌套的使用场景
- 数据(数组,json)的处理
- 自定义key解决zabbix端口监听取值不准确的问题
- Android launcher3 开发初始篇
- 静态页面调试JS出现跨域问题
- [Luogu3768]简单的数学题
- nginx配置备份
- hdu 4486 Pen Counts
- 将句子表示为向量(下):基于监督学习的句子表示学习(sentence embedding)
- 汇编语言调用Linux系统调用read和write
- JAVA 系统变量之System.getenv()和System.getProperty() 用法
- NLayerAppV3-Infrastructure(基础结构层)的Data部分和Application(应用层)
- Object C学习笔记4-内存管理
- 编译geth报错的解决方法 make: *** [geth] 错误 1
- Java中的static关键字的用法
热门文章
- Fence(codeforces 232D)
- .NET结束外部进程 C#结束外部进程
- aspx生成静态页面html 例子
- springboot 邮件
- Qt5网络请求使用及WebRequest函数
- Linux日志审计
- Codeforces Gym100971 F.Two Points (IX Samara Regional Intercollegiate Programming Contest Russia, Samara, March 13)
- sprintf 心得
- Codeforces 761D Dasha and Very Difficult Problem(贪心)
- ssh免秘钥登陆实现