提示有Compilation Error: 1;;但是调试没问题。 另外交一个C++高手,希望可以帮忙我学习~!~ 多谢 10
#include<iostream>usingnamespacestd;intmain(){floatt;while(1){charbuf[1024];cout<<"pl...
#include <iostream>
using namespace std;
int main()
{
float t;
while (1)
{
char buf[1024];
cout<<"please type in a time. When type in t=100,it'll end."<<endl;
cin>>t;
if(!cin.rdstate()) //输入有效性判断
{
enum time {morning=6, noon=12 , afternoon=13 , evening=18, night=21};
if(t>=morning && t<noon)
{
cout<< "good morning."<<endl;
}
if(t>=noon && t<afternoon)
{
cout<<"good noon."<<endl;
}
if(t>=afternoon && t<evening)
{
cout<<"good afternoon."<<endl;
}
if(t>=evening && t<night)
{
cout<<"good evening."<<endl;
}
if((t>=night && t<=24) || (t>=0 && t<morning))
{
cout<<"good night."<<endl;
}
if((t>24 && t!=100) || t<0)
{
cout<<"the input is invalid."<<endl;
}
else if(t==100)
break;
}
else
{
cin.clear(); //清空错误标记
cin>>buf;
cout<<"input error"<<endl;
}
}
return 0;
}
改为交友帖子吧。。。
求C++高手 展开
using namespace std;
int main()
{
float t;
while (1)
{
char buf[1024];
cout<<"please type in a time. When type in t=100,it'll end."<<endl;
cin>>t;
if(!cin.rdstate()) //输入有效性判断
{
enum time {morning=6, noon=12 , afternoon=13 , evening=18, night=21};
if(t>=morning && t<noon)
{
cout<< "good morning."<<endl;
}
if(t>=noon && t<afternoon)
{
cout<<"good noon."<<endl;
}
if(t>=afternoon && t<evening)
{
cout<<"good afternoon."<<endl;
}
if(t>=evening && t<night)
{
cout<<"good evening."<<endl;
}
if((t>=night && t<=24) || (t>=0 && t<morning))
{
cout<<"good night."<<endl;
}
if((t>24 && t!=100) || t<0)
{
cout<<"the input is invalid."<<endl;
}
else if(t==100)
break;
}
else
{
cin.clear(); //清空错误标记
cin>>buf;
cout<<"input error"<<endl;
}
}
return 0;
}
改为交友帖子吧。。。
求C++高手 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询