Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
105941 | 胡海峰老师 | 寻找第二小的数 | C++ | Accepted | 1 MS | 268 KB | 556 | 2025-01-15 09:42:20 |
#include <iostream> using namespace std; int a[20]; int main(){ int n,m; int x1,x2; cin>>n; for(int i=1;i<=n;i++) { x1=200; x2=300; cin>>m; for(int j=1;j<=m;j++) { cin>>a[j]; if(a[j]<x1) x1=a[j]; } for(int j=1;j<=m;j++) { if(a[j]<x2 && a[j]!=x1) x2 = a[j]; } // cout<<"x1="<< x1<<" --- x2="<<x2<< endl; if(x2==300) cout<<"NO\n"; else cout <<x2<<endl; } return 0; } /* Input 3 2 1 2 5 1 1 3 4 5 3 1 1 1 Output 2 3 NO */