1006. Sign In and Sign Out (25)
来源:互联网 发布:惊艳的句子 知乎 编辑:程序博客网 时间:2024/04/29 21:06
#include<iostream>#include<string>#include<fstream>#include<vector>using namespace std;struct record{ string name; int sign_in; int sign_out;};vector<record>records;//time:HH:MM:SSint get_time(const string &time){ int t=0; size_t l=0,n=2; string hh=time.substr(l,n);//之前忘了这个n表示长度,开始一直当做下标了,蛋疼 l=3; string mm=time.substr(l,n); l=6; string ss=time.substr(l,n); cout<<"hh: "<<hh<<" mm: "<<mm<<" ss: "<<ss<<endl; t=3600*atoi(hh.c_str())+60*atoi(mm.c_str())+atoi(ss.c_str()); return t;}int main(){ ifstream cin("data.txt");//一定要及得删除啊亲 int m=0;//record number string in="",out=""; cin>>m; records.resize(m); while(m--){ record rd; cin>>rd.name>>in>>out; rd.sign_in=get_time(in); rd.sign_out=get_time(out); records.push_back(rd); } size_t in_index=0,out_index=0;//开门关门用户所在记录的index for(size_t i=1;i<records.size();++i){ if(records[i].sign_in<records[in_index].sign_in){ in_index=i; } if(records[i].sign_out>records[out_index].sign_out){ out_index=i; } } cout<<records[in_index].name<<" "<<records[out_index].name<<"\n"; system("pause"); }
0 0
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- cocos2d-x3.0版本c++类的lua绑定
- 高仿交通银行手机客户端界面 .
- java中什么时候使用静态static,工具类的创建
- Python函数式编程指南(三):迭代器
- python模块:win32com用法详解
- 1006. Sign In and Sign Out (25)
- 马来西亚:乌克兰政府须对MH17被击落负责
- 江西45家“歪风会所”被关停
- 黑龙江一班12名高考生因思想品德好获“优先录取”
- Android适配开发----Camera
- java与servlet以及java与php完成文件的上传
- 男子应聘后偷走招聘主管钱包
- 安徽:不到2%的返乡农民工选择务农
- javascript学习笔记之javascript core