Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
125611 程诺 两个数的最小距离 C++ Compile Error 0 MS 0 KB 626 2025-07-15 10:40:30

Tests(0/0):


Code:

#include<bits/stdc++.h> using namespace std; int a[1010]; int main(){ //对角线 /* int a[101][101]; */ /** int n,m; cin>>n>>m; for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ cin>>a[i][j]; if(i==j||i+j==n+1){ a[i][j]+=m; } } } for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ printf("%5d",a[i][j]); } cout<<endl; } **/ int min = 10000000; int n; cin>>n; for(int i=1;i<=n;i++){ cin>>a[i]; } for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ if(i!=j){ k = a[i]-a[j]; } if(k<0) k*=-1; if(k<min) min = k; } } cout<<k; return 0; }


Run Info:

Main.cc: In function 'int main()':
Main.cc:35:5: error: 'k' was not declared in this scope
     k = a[i]-a[j];
     ^
Main.cc:37:7: error: 'k' was not declared in this scope
    if(k<0) k*=-1;
       ^
Main.cc:38:7: error: 'k' was not declared in this scope
    if(k