C++风格写判断某年某月某日是一年的第几天
初学C++,在结构体中写函数及一些C++语言需要的一些格式
看代码
#include<iostream>
#include<cstdio>
using namespace std;
struct what_day
{
int year;
int month;
int day;
void count(int year,int month,int day)
{
int s[12]={0,31,28,31,30,31,30,31,31,30,31,30};
int sum=day;
for(int i=0;i<month;i++)
{
sum=sum+s[i];
}
if((year%400||(year%4==0&&year%100))&&month>2)
{
sum++;
}
cout<<sum<<endl;
}
};
int main()
{
cout<<"please input year month day"<<endl;
what_day num;
cin>>num.year>>num.month>>num.day;
num.count(num.year,num.month,num.day);
return 0;
}
C++风格写判断某年某月某日是一年的第几天的更多相关文章
- YTU 2715: 函数---判断某年某月某日是这一年中的第几天
2715: 函数---判断某年某月某日是这一年中的第几天 时间限制: 1 Sec 内存限制: 128 MB 提交: 380 解决: 155 题目描述 在主程序(main)中输入某年某月某日,例如2 ...
- # 【Python3练习题 004】输入某年某月某日,判断这一天是这一年的第几天?
# [Python练习题 004]输入某年某月某日,判断这一天是这一年的第几天? # 思路:先判断是否为闰年,这关系到 2 月份的天数.# 之后再根据月份值把前几个月的天数累积加起来,最后再加上个“日 ...
- python3 输入某年某月某日,判断这一天是这一年的第几天?
题目 输入某年某月某日,判断这一天是这一年的第几天? 程序分析 特殊情况,闰年时需考虑二月多加一天. 代码: import calendar year = int(input("Year:& ...
- python中输入某年某月某日,判断这一天是这一年的第几天?
输入某年某月某日,判断这一天是这一年的第几天?程序分析 特殊情况,闰年时需考虑二月多加一天: 直接上代码 #定义一个函数,判断是否为闰年 def leapyear(y): return (y % 40 ...
- iOS - 日期的时间差(某年某月某日的某一天。。。)
//首先创建格式化对象 NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateF ...
- jquery选择器玩得不6啊,只能慢慢写判断了,唉..........................
jquery选择器玩得不6啊,只能慢慢写判断了,唉..........................
- 使用switch计算出某年某月某日是今年的第几天,输出一直是当月天数
package com.cx.Switch; import java.util.Scanner; /** * 计算出某年某月某日是今年的第几天 * 使用switch */ public class S ...
- js 输出某年某月某日的天数/判断闰年
console.log(getDays(2017,12,12)); function getDays(year,month,day){ var arr = [31,28,31,30,31,30,31, ...
- 输入某年某月某日,判断这一天是这一年的第几天?(可以用 Python 标准 库)
import datetime def dayofyear(): year = input("请输入年份:") month = input("请输入月份:") ...
随机推荐
- Binary Watch
Binary Watch 描述 Consider a binary watch with 5 binary digits to display hours (00 - 23) and 6 binary ...
- 文件夹添加 IIS 应用程序池用户权限
http://serverfault.com/questions/81165/how-to-assign-permissions-to-applicationpoolidentity-account ...
- angularJs中ngModel的坑
angular中指令被用的最多的除了ng-repeat之外就非他莫属了吧,由于各种业务的需求,我们经常需要去写一些继承ngModel的指令,来满足各种奇葩需求,最多的莫过于表单的验证啦,另外你在封装一 ...
- 深入浅出Ajax(五)
function initPage() { alert("3+3");//3+3 alert(eval("3+3")); //6 //eval()函数可以解析. ...
- FatMouse's Speed 基础DP
FatMouse's Speed Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- PAT (Advanced Level) 1017. Queueing at Bank (25)
简单模拟. #include<iostream> #include<cstring> #include<cmath> #include<algorithm&g ...
- ScrollView的fillViewPort属性
ScrollView嵌套Relative时候会发生问题,RelativeLayout不会充满ScrollView,即使设置match_parent属性也不行 这个时候就需要fillViewPort属性 ...
- C#使用FFmpeg 将视频格式转换成MP4示例
一.常用视频格式分辨率 640x480p 720p格式,分辨率为1280×720p / 60Hz,行频为45kHz 1080p格式,分辨率为1920×1080逐行扫描,专业格式 二.FFmpeg部分参 ...
- iOS之PCH文件
在Xcode6之前,创建一个新工程xcode会在Supporting files文件夹下面自动创建一个“工程名-Prefix.pch”文件,也是一个头文件,pch头文件的内容能被项目中的其他所有源文件 ...
- php 安装php5-mysql 拓展
Your PHP installation appears to be missing the MySQL extension which is required by WordPress Error ...