初学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. JAVA Timer定时器使用方法(二)

    JAVA  Timer 定时器测试 MyTask.java:package com.timer; import java.text.SimpleDateFormat;import java.util. ...

  2. Swift中异常处理(续集.正则)

    正则表达式 1.创建正则表达式的规则 let pattern = "abc" 2.创建正则表达式对象 // 方式一:try方式 do { let regex = try NSReg ...

  3. Codeforces Round #369 (Div. 2) C. Coloring Trees (DP)

    C. Coloring Trees time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  4. mariadb cache

    Since MariaDB Galera cluster versions 5.5.40 and 10.0.14 you can use the query cache. Earlier versio ...

  5. CodeForces 616C The Labyrinth

    先预处理出所有连通块,对于每一个*,看他四周的连通块即可 #include<cstdio> #include<cstring> #include<queue> #i ...

  6. 计算机学院大学生程序设计竞赛(2015’12) 1008 Study Words

    #include<cstdio> #include<cstring> #include<map> #include<string> #include&l ...

  7. JavaScript(三)---- 控制流程语句

    常用的控制流程语句有判断语句.分支语句.循环语句.基本用法都和java中的一致,switch有几点特殊. 1.判断语句 格式:        if(判断条件){            符合条件执行的代 ...

  8. mysql安装使用----1 安装和启动

    1 安装 Fedora16/17 Mysql 安装及配置 1.安装 Mysql Server # yum install mysql mysql-server 2.开启 MySQL server 及开 ...

  9. iOS之UILabel自适应大小

    //初始化一个label self.label=[[UILabel alloc] init]; //设置自动行数与字符换行 [self.label setNumberOfLines:0]; //给la ...

  10. cocos2dx 3.2 的中国象棋游戏

    改编来源:http://cn.cocos2d-x.org/tutorial/lists?id=103 在cocos2dx官网看到了这么个教程,是cocos2dx 2.x版本的,于是用 cocos2dx ...