#include <iostream>
using namespace std;
struct date{
int year;
int month;
int day;
};
bool Judgeyear(int year){ //判闰年
bool tag = 0;
if((year%100 != 0 && year%4 == 0)||year %400 == 0)
tag = 1;
return tag;
}
int Counmonth(int month,int year){ //月份-天数换算
int sum = 0;
int a[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
int b[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
if(Judgeyear(year) == 1){
for(int i = 0;i<month-1;i++){
sum += b[i];
}
}
else{
for(int i = 0;i<month-1;i++){
sum +=a[i];
}
}
return sum;
}
int Plusdata(int day,int month,int year){ //天数总值
int all = day+Counmonth(month,year);
return all;
}
int main(){
date date;
cin >> date.year >> date.month >>date.day;
cout << Plusdata(date.day,date.month,date.year);
return 0;
}
0.0分
6 人评分
#include <iostream> using namespace std; struct date{ int year; int month; int day; }; bool Judgeyear(int year){ //判闰年 bool tag = 0; if((year%100 != 0 && year%4 == 0)||year %400 == 0) tag = 1; return tag; } int Counmonth(int month,int year){ //月份-天数换算 int sum = 0; int a[12] = {31,28,31,30,31,30,31,31,30,31,30,31}; int b[12] = {31,29,31,30,31,30,31,31,30,31,30,31}; if(Judgeyear(year) == 1){ for(int i = 0;i<month-1;i++){ sum += b[i]; } } else{
简单的a+b (C语言代码)浏览:764 |
奖学金 (C++代码)浏览:2053 |
多输入输出练习1 (C语言代码)浏览:1219 |
回文数(一) (C语言代码)浏览:809 |
ASCII帮了大忙浏览:797 |
C语言程序设计教程(第三版)课后习题6.4 (C语言代码)浏览:639 |
计算质因子 (C++代码)浏览:1824 |
大神老白 (C语言代码)浏览:690 |
printf基础练习2 (有点不明白)浏览:887 |
用筛法求之N内的素数。 (C语言代码)浏览:890 |