/*
*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)