题解 | 找最小数

找最小数

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

#include<iostream>
using namespace std; 
int main(){
	int n;
	cin>>n;
//	起到一个标志的作用 
	int ans=0;
	int x1,x2;
//	int y1,y2;
	while(n--){
		int a;
		int b;
		cin>>a>>b;
		if(ans==0){
			x1=a;
			x2=b; 
			ans=1;
		}
		if(x1>a){
			x1=a;
			x2=b;
		}else if(x1==a && x2>b){
			x1=a;
			x2=b;
		}
		
	}
	cout<<x1<<" "<<x2;
} 

不难,这道题的思路是比较简单的,对于刚开始学习语法的同学来说可能是比较难一点,但是加油就好!!!我感觉自己很笨,多写就好啦!

全部评论

相关推荐

axiom15:校友,我感觉你这个简历去华子暑期实习随便去了
点赞 评论 收藏
分享
马上就好了:HR看了以为来卧底来了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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