网易2018实习招聘计算机视觉岗笔试编程题
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main()
{
int n, x;
cin >> n;
vector<vector<int> > time;
time.resize(n);
for (int i = 0; i < n; i++)
time[i].resize(2);
for (int i = 0; i < n; i++)
{
cin >> time[i][0];
cin >> time[i][1];
}
cin >> x;
vector<int> class_time(2);
cin >> class_time[0];
cin >> class_time[1];
int hour = 0;
int min = 0;
int min_late = 65535;
int cur_late = 0;
int num_time = 0;
for (int i = 0; i < n; i++)
{
hour = class_time[0] - time[i][0];
min = class_time[1] - time[i][1];
cur_late = hour * 60 + min;
if (cur_late <= min_late && cur_late >= x)
{
min_late = cur_late;
num_time = i;
}
}
cout << time[num_time][0] << " " << time[num_time][1] << endl;
return 0;
}
#实习#
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main()
{
int n, x;
cin >> n;
vector<vector<int> > time;
time.resize(n);
for (int i = 0; i < n; i++)
time[i].resize(2);
for (int i = 0; i < n; i++)
{
cin >> time[i][0];
cin >> time[i][1];
}
cin >> x;
vector<int> class_time(2);
cin >> class_time[0];
cin >> class_time[1];
int hour = 0;
int min = 0;
int min_late = 65535;
int cur_late = 0;
int num_time = 0;
for (int i = 0; i < n; i++)
{
hour = class_time[0] - time[i][0];
min = class_time[1] - time[i][1];
cur_late = hour * 60 + min;
if (cur_late <= min_late && cur_late >= x)
{
min_late = cur_late;
num_time = i;
}
}
cout << time[num_time][0] << " " << time[num_time][1] << endl;
return 0;
}
#实习#