1个回答
展开全部
#include<iostream>
using namespace std;
int main(){
int hour,minute,second;
bool goon=1;
char signal;
while(goon){
cout<<"请依次输入24小时制的时分秒,中间以空格间隔开:";
cin>>hour>>minute>>second;
if(hour>24||minute>60||second>60){ cout<<"您输入的时间有误!"<<endl;}
else if(hour<12){cout<<"现在时间上午"<<hour<<"小时"<<minute<<"分"<<second<<"秒"<<endl;}
else if(hour==12){cout<<"现在时间下午"<<hour<<"小时"<<minute<<"分"<<second<<"秒"<<endl;}
else{cout<<"现在时间下午"<<hour-12<<"小时"<<minute<<"分"<<second<<"秒"<<endl;}
cout<<"是否继续输入?(Y/N):";
cin>>signal;
if(signal=='N'||signal=='n') goon=0;
}
return 0;
}
using namespace std;
int main(){
int hour,minute,second;
bool goon=1;
char signal;
while(goon){
cout<<"请依次输入24小时制的时分秒,中间以空格间隔开:";
cin>>hour>>minute>>second;
if(hour>24||minute>60||second>60){ cout<<"您输入的时间有误!"<<endl;}
else if(hour<12){cout<<"现在时间上午"<<hour<<"小时"<<minute<<"分"<<second<<"秒"<<endl;}
else if(hour==12){cout<<"现在时间下午"<<hour<<"小时"<<minute<<"分"<<second<<"秒"<<endl;}
else{cout<<"现在时间下午"<<hour-12<<"小时"<<minute<<"分"<<second<<"秒"<<endl;}
cout<<"是否继续输入?(Y/N):";
cin>>signal;
if(signal=='N'||signal=='n') goon=0;
}
return 0;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询