您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
这篇文章主要介绍“如何编写代码实现航班时间效果”,在日常操作中,相信很多人在如何编写代码实现航班时间效果问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”如何编写代码实现航班时间效果”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!
string line;
getline(cin,line);
#include<iostream> #include<cstring> #include<cstdio> #include<algorithm> using namespace std; int get_seconds(int h,int m,int s){ return h*3600+m*60+s; } int get_time(){ string line; getline(cin,line); if(line.back() != ')') line+="(+0)"; int h2,m1,s1,h3,m2,s2,d; sscanf(line.c_str(),"%d:%d:%d %d:%d:%d (+%d)",&h2,&m1,&s1,&h3,&m2,&s2,&d); return get_seconds(h3,m2,s2) - get_seconds(h2,m1,s1) + d*24*3600; } int main(){ int n; cin>>n; string line; //忽略掉第一行的回车 getline(cin,line); while(n--){ int time=(get_time()+get_time())/2; printf("%02d:%02d:%02d\n",time/3600,time%3600/60,time%60); } return 0; }
到此,关于“如何编写代码实现航班时间效果”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注亿速云网站,小编会继续努力为大家带来更多实用的文章!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。