#10709. 枚举算法第四题(NOIP2010)

枚举算法第四题(NOIP2010)

第四题(NOIP2010)

#include<iostream>
using namespace std;
int main() {
    const int SIZE = 10;
    int data[SIZE], i, j, cnt, n, m;
    cin >> n >> m;
    for (i = 1; i <= n; i++)
        cin >> data[i];
    for (i = 1; i <= n; i++) {
        cnt = 0;
        for (j = 1; j <= n; j++)
            if ((data[i] < data[j]) || (data[j] == data[i] && j < i))
                cnt++;
        if (cnt == m)
            cout << data[i] << endl;
    }
    return 0;
}
  1. 【判断题】若输入的n大于等于10,则程序可能发生运行时错误。 {{ select(1) }}
  • 正确
  • 错误
  1. 【判断题】若输入的m大于等于n,则程序没有输出。 {{ select(2) }}
  • 正确
  • 错误
  1. 【判断题】若把第14行的=换成>=,则程序运行结果不变。 {{ select(3) }}
  • 正确
  • 错误
  1. 【判断题】输入5 2 96 -8 0 16 87,则会输出17。 {{ select(4) }}
  • 正确
  • 错误
  1. 【选择题】输入6 3 1 5 3 7 8 4,则输出为( )。 {{ select(5) }}
  • 1
  • 3
  • 4
  • 5
  1. 【选择题】程序的时间复杂度为( )。 {{ select(6) }}
  • O(n)
  • O(logn)
  • O(nlogn)
  • O(n²)