📄 date.cpp
字号:
//////////////////////////////////////////////////////////////////////////////////
////////file: Date.cpp
#include <iostream.h>
void Date(int y, int m, int d);
void main()
{
cout<<"Please input a positive int standed for the year:"<<endl;
int year;
cin>>year;
cout<<"Please input a int standed for the month between 0 and 12:"<<endl;
int month;
cin>>month;
cout<<"Please input a int standed for the date of the right scope due to the different month:"<<endl;
int day;
cin>>day;
Date(year, month, day);
}
void Date(int y, int m, int d)
{
int year=y;
int month=m;
int day=d;
int date=0;
if((year%4)!=0)
{
switch (month)
{
case 1: case 2:
date=(month-1)*31+day;
cout<<"the date is:"<<date<<endl;
break;
case 3: case 4: case 5: case 6: case 7: case 8:
date=(month/2)*31+((month-3)/2)*30+28+day;
cout<<"the date is:"<<date<<endl;
break;
case 9: case 10: case 11: case 12:
date=((month+1)/2)*31+((month-4)/2)*30+28+day;
cout<<"the date is:"<<date<<endl;
break;
default:
cout<<"error!"<<endl;
}
}
else
{
switch (month)
{
case 1: case 2:
date=(month-1)*31+day;
cout<<"the date is:"<<date<<endl;
break;
case 3: case 4: case 5: case 6: case 7: case 8:
date=(month/2)*31+((month-3)/2)*30+29+day;
cout<<"the date is:"<<date<<endl;
break;
case 9: case 10: case 11: case 12:
date=((month+1)/2)*31+((month-4)/2)*30+29+day;
cout<<"the date is:"<<date<<endl;
break;
default:
cout<<"error!"<<endl;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -