第12周项目4-计算当年第几天(二)
来源:互联网 发布:安卓竖屏桌面软件 编辑:程序博客网 时间:2024/04/30 18:09
/*
*Copyright (c)2013,烟台大学计算机学院
*All rights reserved.
*作 者:孔云
*完成日期:2013年11月16日
*版 本 号:v1.0
*问题描述:计算当年第几天。
*问题分析:利用条件结构,计算出当年第几天。
*/
#include <iostream>
using namespace std;
int days(int);
int main()
{
int n,y,r,sum;
cout<<"请输入年月日:"<<endl;
cin>>n>>y>>r;
cout<<"本年的第"<<sum<<"天"<<endl;
return 0;
}
int days (int n,int y,int r)
{
int sum;
sum=r;
for(int i=1; i<y; i++)
{
if(i==1 || i==3 || i==5 || i==7 || i==8 || i==10 || i==12)
sum+=31;
else if(i==4 || i==6 || i==9 || i==11)
sum+=30;
else
sum+=(n%4==0 && n%100!=0 || n%400==0)?29:28;
}
return sum;
}
心得体会:甲光向日金鳞开,Come on!
- 第12周项目4-计算当年第几天(二)
- 第12周项目3-计算当年第几天(一)
- 计算当年第几天
- 第12周项目1--当年第几天
- 第12周项目1:当年第几天
- 第17周项目4当年第几天
- 第17周项目4 日期结构体——当年第几天 版本二
- 第十二周项目一 当年第几天
- 第十二周项目1-当年第几天
- 第十七周 项目四 当年第几天
- 第七周项目二自选图形用户界面程序开发(当年第几天)
- 第17周项目4-当年第几天(结构体)
- 第17周项目4-日期结构体(1)当年第几天
- 第6周-二试窗口-当年第几天
- 第11周项目5-当年第几天
- 第11周项目5-当年第几天
- 第11周项目五 当年第几天
- 第11周项目5 当年第几天
- 【MoreWindows工作笔记3】 使用cout/pintf输出16进制,8进制,2进制数据
- 黑马程序员---内部类与异常
- Android_ListView_onTouchEvent源码分析
- Ubuntu中firefox chromium安装flash插件
- 几种常见排序算法
- 第12周项目4-计算当年第几天(二)
- 命令启动程序
- ubuntu配置记录
- 淘宝经营策略-小谈操盘手
- 1150. 简单魔板
- 实现报名人信息与存储库中信息同步显示
- BSTR
- Sudoku Killer
- S3C2440的LCD