📄 4.cpp
字号:
/*---------------------------------------例题4-------------------------------------------------------------------*/
#include <iostream>
using namespace std;
int main()
{
int _year, _month, _day;
int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};//用数组存储非闰年的天数
cout<<"Please input the year:"<<endl;
cin>>_year;
cout<<"Please input the month:"<<endl;
cin>>_month;
cout<<"Please input the day:"<<endl;
cin>>_day;
if(_year % 4 == 0 && _year / 100 != 0 || _year % 400 == 0) //判断是否是闰年
day[1] ++; //如果是闰年,二月份是29天
for(int i = 0; i<_month - 1; i++)
_day += day[i];
cout<<"It is day "<<_day<<" of year "<<_year<<endl;
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -