标签:
初学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;
}
标签:
原文地址:http://www.cnblogs.com/liudehao/p/5663168.html