题解 | 找最小数
找最小数
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;
}
不难,这道题的思路是比较简单的,对于刚开始学习语法的同学来说可能是比较难一点,但是加油就好!!!我感觉自己很笨,多写就好啦!
