题解 | #找最小数#

找最小数

https://www.nowcoder.com/practice/ba91786c4759403992896d859e87a6cd

//土尔逊Torson 编写于2023/4/14
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <algorithm>
#include <stdlib.h>

using namespace std;

const int nMax = 1001;

struct NLab {
	int x;
	int y;
};

bool comp0331(NLab left, NLab right) {
	if (left.x < right.x) {
		return true;
	}
	else if (left.x == right.x && left.y < right.y) {
		return true;
	}
	else {
		return false;
	}
}

int main() {
	int n;
	NLab arr[nMax];
	while (scanf("%d", &n) != EOF) {

		for (int i = 0; i < n; ++i) {
			scanf("%d %d", &arr[i].x, &arr[i].y);
		}
		
		sort(arr, arr + n, comp0331);

		printf("%d %d", arr[0].x, arr[0].y);
	}
	system("pause");
	return EXIT_SUCCESS;
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

05-09 14:45
门头沟学院 Java
点赞 评论 收藏
分享
ResourceUtilization:差不多但是估计不够准确,一面没考虑到增长人口,另一方面也没考虑到能上大学的人数比例,不过我猜肯定只多不少
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务