Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
152342 鲁博睿 打印每一趟选择排序 C++ Compile Error 0 MS 0 KB 492 2026-04-25 14:29:59

Tests(0/0):


Code:

#include<bits/stdc++.h> using namespace std; int a[n]; int main(){ int n; cin >> n; for (int i = 0; i <= n - 1; i++) { cin >> a[i]; } int sum= 0; int t=0; for (int j = 0; j <= n - 2; j++) { sum = j; for (int i = j+1; i <= n - 1; i++) { if (a[sum] > a[i]) { sum = i; } } t = a[j]; a[j] = a[sum]; a[sum] = t; for (int i = 0; i <= n - 1; i++) { cout << a[i] << " "; } cout<<endl; } return 0; }


Run Info:

Main.cc:3:7: error: 'n' was not declared in this scope
 int a[n]; 
       ^
Main.cc: In function 'int main()':
Main.cc:8:11: error: 'a' was not declared in this scope
    cin >> a[i]; 
           ^
Main.cc:15:9: error: 'a' was not declared in this scope
     if (a[sum] > a[i]) { 
         ^
Main.cc:19:7: error: 'a' was not declared in this scope
   t = a[j]; 
       ^