天啊,我怎么可以这样子,太着急没有去掉注释,导致oppo败笔

是这样的,今晚的笔试题,我个人觉得不难,但是我因为身体不适,就比较耽误时间。第一题我完全可以ac,我检查了一下本地,我忘记去掉注释了,请求oppo给我一个机会让我发光发热。代码如下:
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
	int n, k;
	while (cin >> n >> k)
	{
		//cout << endl << "n=" << n << ",k=" << k << endl;
		vector<vector<int>> arr(n, vector<int>(2));
		for (int i = 0; i < n; i++)
		{
			cin >> arr[i][0] >> arr[i][1];
		}
		sort(arr.begin(), arr.end());
		set<string> delta_xy_set;
		double ans;
		for (int i = 0; i < n-1; i++)
		{
			int deltax = arr[i][0] - arr[i+1][0];
			int deltay = arr[i][1] - arr[i + 1][1];
			if ((deltax != 0)&& (deltay != 0))
			{
				string str = to_string(deltay);
				str += "_";
				str += to_string(deltax);
				if(!delta_xy_set.count(str))
					delta_xy_set.insert(str);
			}
			
		}
		int j = 0;
		for (auto it= delta_xy_set.begin();it!= delta_xy_set.end();it++)
		{

			if (j == k)
			{
				int p;
				string s = (*it);
				string strx ,stry;
				int x = 0;
				for ( ;x < s.size(); x++)
				{
					if (s[x] == '_')
						break;
					else
						stry += s[x];
				}
				x++;
				for (; x < s.size(); x++)
				{
					strx += s[x];
				}
				int y = stoi(stry) ;
				int x2 = stoi(strx);
				p=y/x2;
				cout<<"*it =" <<p << endl;
				break;
			}
			else {
				j++;
			}
		}
	}
	return 0;
}

不知道能不能被看到,好i想哭啊!这题我完全会
#OPPO##笔试题型#
全部评论
应该不会看代码,只看结果的
1 回复 分享
发布于 2020-09-23 21:05
呃,没其他恶意,只是单纯问下,北外也有搞C++的啊😥
点赞 回复 分享
发布于 2020-09-24 10:26
没事的,还有其他机会的
点赞 回复 分享
发布于 2020-09-24 07:33

相关推荐

不愿透露姓名的神秘牛友
08-08 18:20
职场水母:这题思路是什么,我目前想的一个暴力方法就是先把这个链表遍历一遍,用哈希表存储出现次数,然后再根据哈希表来一个一个删除节点,
点赞 评论 收藏
分享
牛客37328580...:个人感觉项目只是列出来了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务