初学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++风格写判断某年某月某日是一年的第几天的更多相关文章

  1. YTU 2715: 函数---判断某年某月某日是这一年中的第几天

    2715: 函数---判断某年某月某日是这一年中的第几天 时间限制: 1 Sec  内存限制: 128 MB 提交: 380  解决: 155 题目描述 在主程序(main)中输入某年某月某日,例如2 ...

  2. # 【Python3练习题 004】输入某年某月某日,判断这一天是这一年的第几天?

    # [Python练习题 004]输入某年某月某日,判断这一天是这一年的第几天? # 思路:先判断是否为闰年,这关系到 2 月份的天数.# 之后再根据月份值把前几个月的天数累积加起来,最后再加上个“日 ...

  3. python3 输入某年某月某日,判断这一天是这一年的第几天?

    题目 输入某年某月某日,判断这一天是这一年的第几天? 程序分析 特殊情况,闰年时需考虑二月多加一天. 代码: import calendar year = int(input("Year:& ...

  4. python中输入某年某月某日,判断这一天是这一年的第几天?

    输入某年某月某日,判断这一天是这一年的第几天?程序分析 特殊情况,闰年时需考虑二月多加一天: 直接上代码 #定义一个函数,判断是否为闰年 def leapyear(y): return (y % 40 ...

  5. iOS - 日期的时间差(某年某月某日的某一天。。。)

    //首先创建格式化对象 NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateF ...

  6. jquery选择器玩得不6啊,只能慢慢写判断了,唉..........................

    jquery选择器玩得不6啊,只能慢慢写判断了,唉..........................

  7. 使用switch计算出某年某月某日是今年的第几天,输出一直是当月天数

    package com.cx.Switch; import java.util.Scanner; /** * 计算出某年某月某日是今年的第几天 * 使用switch */ public class S ...

  8. js 输出某年某月某日的天数/判断闰年

    console.log(getDays(2017,12,12)); function getDays(year,month,day){ var arr = [31,28,31,30,31,30,31, ...

  9. 输入某年某月某日,判断这一天是这一年的第几天?(可以用 Python 标准 库)

    import datetime def dayofyear(): year = input("请输入年份:") month = input("请输入月份:") ...

随机推荐

  1. Gerald and Giant Chess

    Gerald and Giant Chess time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  2. 使用Metasploit入侵windows之自动扫描

    最新版本的metasploit为4.0,可以通过官方网站(www.metasploit.com)直接下载,因为是开源的,所以免费. metasploit很好很强大,集成了700多种exploit,但是 ...

  3. 启动ipython notebook(jupyter)

    启动本地notebook 随便找一个shell,在windows里,最简单的cmd.exe就行,键入: ipython.exe notebook

  4. inline-block的特点

    <html> <head> <meta charset="utf-8"> <title></title> <sty ...

  5. Codeforces Round #367 (Div. 2)D. Vasiliy's Multiset (字典树)

    D. Vasiliy's Multiset time limit per test 4 seconds memory limit per test 256 megabytes input standa ...

  6. Installation error: INSTALL_FAILED_UPDATE_INCOMPATIBLE

    Installation error: INSTALL_FAILED_UPDATE_INCOMPATIBLE 晚上在测一个widget,前面测的好好的,后面再安装的时候发现如下错误:[2009-06- ...

  7. gitlab应用

    1.git config --global user.email "my@bimt.com" //注册本地环境 2.ssh-keygen -t rsa -C "my@bi ...

  8. 品牌笔记本预装windows的OEM分区解决方案(联想)

    我的Y480出厂预装的win7,现在过了好久了,系统早就格盘重装成win8.1了,但是分区表里面还有个OEM分区.里面存的应该是预装的系统备份,跟笔记本电源键旁边的恢复键直接绑定......不过系统既 ...

  9. spring MVC 初探 (HelloWorld)

    1.使用spring MVC 需要导入相关jar包 2.web.xml 启用spring MVC <servlet> <servlet-name>spring3mvc</ ...

  10. Nginx负载均衡策略

    目前nginx负载均衡支持的5种方式的分配 1. 轮询 每个请求按时间顺序逐一分配到不同的后端服务器,如果后端服务器down掉,能自动剔除. upstream backserver { server ...