C++编程:定义一个结构体变量(包括年、月、日),编写程序,要求输入年月日,程序能够计算并输出改日是本年中的第几天。注意闰年问题。
以下是此题的【c++源代码】,需要【c源代码】请点击进入
源代码1:
#include
using namespace std;
struct
{ int year;
int month;
int day;
}date;
int main()
{int days;
cout<
cin>>date.year>>date.month>>date.day;
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