Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
3010 莫业祁 两个数的最小距离II C++ Accepted 2 MS 264 KB 521 2024-03-16 17:24:25

Tests(15/15):


Code:

# include<iostream> # include<cmath> using namespace std; int n,temp=0; int a[1002]; int Min=1000000000,I=0,J=0; int main(){ cin>>n; for(int i=1;i<=n;i++) cin>>a[i]; for(int i=1;i<n;i++){ for(int j=i+1;j<=n;j++){ if(a[i]-a[j]<0) temp=(a[i]-a[j])*-1; else temp=(a[i]-a[j])*1; if(temp<Min){ Min=temp; I=i; J=j; } } } cout<<I<<' '<<J; return 0; }