首页 > 试题广场 >

找最小数

[编程题]找最小数
  • 热度指数:24990 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 64M,其他语言128M
  • 算法知识视频讲解
第一行输入一个数n,1 <= n <= 1000,下面输入n行数据,每一行有两个数,分别是x y。输出一组x y,该组数据是所有数据中x最小,且在x相等的情况下y最小的。 

输入描述:
输入有多组数据。
每组输入n,然后输入n个整数对。


输出描述:
输出最小的整数对。
示例1

输入

5  
3 3  
2 2  
5 5  
2 1  
3 6

输出

2 1
头像 Huster水仙
发表于 2023-01-06 20:36:03
//只用比较,不用存储所有数据 #include<iostream> using namespace std; int main(){     int n,x,y,xmin,ymin;     scanf("%d",&n); &nb 展开全文
头像 aaaawei
发表于 2021-01-08 20:40:40
先定义两个int的结构体 然后对结构体排序 自定义排序算法 从小到大排序最后取第一组结构体就是最小的数这种方法适合输入很多组数据时候的代码 排序一次能得到从小到大的结构体#include<iostream>#include<cstdio>#include<alg 展开全文
头像 渺小小螃蟹
发表于 2021-05-10 16:28:38
//这么写好快的 #include<stdio.h> int main() { int n,a[2][1000]={0},flag=0; while(scanf("%d",&n)!=EOF) { int i,j; for( 展开全文
头像 牛烘烘
发表于 2022-03-24 19:09:26
#include<iostream> #include<cstdio> #include<algorithm> using namespace std; const int maxn=1000+10; struct cmp{      展开全文
头像 Vinnnnnci
发表于 2023-02-18 09:19:42
pair配对+sort排序(利用字典默认先比较first,再比较second) #include<cstdio> #include<utility> #include<algorithm> using namespace 展开全文
头像 云水间
发表于 2023-02-12 17:36:41
#include <stdio.h> #include <stdlib.h> typedef struct nums{ int x; int y; }NUMS; int cmp(const void*a,const void*b){ if(((NUMS 展开全文
头像 复旦周杰伦
发表于 2023-02-28 22:27:38
#include <cstdio> int main() { int n; scanf("%d\n",&n); int arr[n][2]; for(int i=0;i<n;i++){ scanf("%d%d",&arr[i][0] 展开全文
头像 兔兔加大油
发表于 2026-03-09 11:00:06
#include <iostream> #include <map> #include <vector> using namespace std; int main() { int n,a,b,s; cin >> n; multimap&l 展开全文
头像 在考古的小鱼干很有气魄
发表于 2023-03-18 11:56:02
#include <bits/stdc++.h> #define INF 0x3f3f3f3f using namespace std; int main(){ int n,mina = INF,minb = INF,a,b; cin>>n; while(n--){ 展开全文
头像 算法废物
发表于 2023-03-26 23:18:56
#include <algorithm> #include <iostream> #include <vector> using namespace std; //用类来存储x,y,通过vector存储,利用sort按照排序要求排序后输出vector[0]即可 c 展开全文