01 #include<iostream> 02 #include<cstring> 03 #include<cstdio> 04 #define N 500 + 10 05 using namespace std; 06 int a[N], n; 07 int main() { 08 cin >> n; 09 for (int i = 1; i <= n; i++) cin >> a[i]; 10 for (int i = 1; i < n; i++) { 11 int tmp = i; 12 for (int j = i + 1; j <= n; j++) 13 if (a[j] < a[tmp]) tmp = j; 14 swap(a[i], a[tmp]); 15 } 16 for (int i = 1; i <= n; i++) cout << a[i] << " "; 17 cout << endl; 18 return 0; 19 }
1. 上述代码实现了对一个长度为 n 的序列进行排序( )
2. 去掉头文件 #include 后程序仍能正常编译运行( )
3. 去掉 using namespace std; 后程序仍能正常编译运行( )
4. 我们将上述算法称为( )
5. 上述代码的时间复杂度为( )
6. 若输入数据为: 5 3 2 1 5 4 则 if(a[j] < a[tmp]) 这句话中的条件会成立多少次(即后面的 tmp = j 会被执行多少次)( )