急!!大家帮我看一下,为什么运行不了
一个查日期或输出系统当前日期的程序,不报错,但是却没有输出结果# include<iostream.h>
# include<stdlib.h>
# include<time.h>
# include<conio.h>
class date{
public:
date()
{days[0]=31,days[1]=28,days[2]=31,days[3]=30,days[4]=31,days[5]=30,days[6]=31,
days[7]=31,days[8]=30,days[9]=31,days[10]=30,days[11]=31;
}
void one(int a,int b,int c)
{year=a,month=b,day=c;}
void now()
{time_t nowtime;
struct tm *p;
time(&nowtime);
p=localtime(&nowtime);
year=1900+p->tm_year,month=1+p->tm_mon,day=p->tm_mday;
}
void output()
{
if((year%4==0)&&(year%100!=0)||(year%400==0))
days[1]++;
while(1)
{if(getch()=='+')
{day=day+1;
if(day>days[month-1])
month=month+1,day=1;
if(month>12)
year=year+1,month=1,day=1;
cout<<year<<month<<day<<endl;
}
if(getch()=='0')
exit(0);
}
}
private:
int year,month,day;
int days[12];
};
void main()
{
int a,b,c;
date op;
cout<<"need input data? yes press 1 no press 2"<<endl;
cin>>a;
if(a==1)
{
cin>>a>>b>>c;
op.one(a,b,c);
op.output();
}
if(a==2)
{
op.now();
op.output();
}
}