17 weeks (structure calculation days)

Source: Internet
Author: User

/*
*copyright (c) 2014, College of Computer Science, Yantai University
*all rights reserved.
* File Name: 17 weeks (structure calculation days)

* Wangzhong
* Completion Date: 2014.12.22

* Version Number: v1.0
*
* Problem Description: Defines a struct variable (including year, month, day) that requires input of the year, month, and day, which is the day ordinal of the year.

* Input Description: Enter year, month, day

* Program output: the date of the output is the day ordinal of the year.

 #include <iostream>using namespace std;struct date{int year;    int month; int day;};    int main () {date date;    cout<< "input year,month,day:";    cin>>date.year>>date.month>>date.day;    int days;    Calculate days switch (date.month) {case 1:days=date.day;break;    Case 2:days=date.day+31;break;    Case 3:days=date.day+59;break;    Case 4:days=date.day+90;break;    Case 5:days=date.day+120;break;    Case 6:days=date.day+151;break;    Case 7:days=date.day+181;break;    Case 8:days=date.day+212;break;    Case 9:days=date.day+243;break;    Case 10:days=date.day+273;break;    Case 11:days=date.day+304;break;    Case 12:days=date.day+334;break; } if ((date.year%4==0&&date.year%100!=0) | | |    date.year%400==0) &&date.month>=3) days=days+1; cout<<date.month<< "Month" <<date.day<< "Day is" <<date.year<< "year" <<days< < "day."    <<endl; return 0;} 


17 weeks (structure calculation days)

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.