C + + style write to judge a certain day of the year is one of the first days of the year

Source: Internet
Author: User

Beginner C + +, writing functions in structs and some of the formats required by some C + + languages

Look at the code

#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" <<endl;
What_day num;
cin>>num.year>>num.month>>num.day;
Num.count (Num.year,num.month,num.day);
return 0;
}

C + + style write to judge a certain day of the year is one of the first days of the year

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.