【求助】时间计算
输入年月日和星期几,再输入n,计算前n天的日期和星期几?我写了一个可出现fatal error C1189: #error : "eh.h is only for C++!"执行 cl.exe 时出错.
怎么回事啊?
#include<iostream>
using namespace std;
void main()
{
int f1(int x);
int k,y1,m1,d1,n,y2,m2,d2,y,t;
cout<<"输入年y1月m1日d1和星期几y和天数n"<<endl;
cin>>y1>>m1>>d1>>y>>n;
t=n%7;
x=y+t;
m2=m1;y2=y1;
n=n-d1-1;
m2--;
if(m2<1) y2--;
d2=f1(m2);
while(n>0)
{k=f1(m2);
n=n-k;m2--;
if(m2<1)y2--;
}
d2=f1(m2)-n;
cout<<"年:"<<y2<<"月:"<<m2<<"日:"<<d2<<"星期:"<<x<<endl;
}
int f1(int x)
{int p;
switch(x){
case 12:
case 10:
case 8:
case 7:
case 5:
case 3:
case 1:p=31;break;
case 2:{if(y1%400==0||(y1!=100&&y1%4==0)) p=29;
else p=28;break;}
case 4:
case 6:
case 9:{p=30;break;}
default:break;
}
return p;
}