我写了一个日历代码,但我有一些杂散错误。这是我的代码:
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
int month, year, Y, M;
int day[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int FirstDayofMonth;
cout<<"please enter year!"<<endl;
cin>>year;
while(year<1600)
{
cout<<"please do not enter year less than 1600!"<<endl;
cin>>year;
}
cout<<"please enter month! (1~12)"<<endl;
cin>>month;
Y = year – (14 – month)/12;
M = month + 12 * ((14 - month) / 12) - 2;
FirstDayofMonth = (Y+Y/4-Y/100+Y/400+31*M/12+1)%7;
}
另一部分是打印结果。它向我显示了下面的错误
try.cpp:18: error: stray ‘\342’ in program
try.cpp:18: error: stray ‘\200’ in program
try.cpp:18: error: stray ‘\223’ in program
try.cpp:18: error: stray ‘\342’ in program
try.cpp:18: error: stray ‘\200’ in program
try.cpp:18: error: stray ‘\223’ in program
try.cpp: In function ‘int main()’:
try.cpp:18: error: expected `)' before ‘month’
try.cpp:18: error: ‘year’ cannot be used as a function
18:Y = year – (14 – month)/12;
我不知道错误是什么意思,有人可以帮助我吗?谢谢!!