如果你想取不重复的10个数,生成20个随机数,取最大或最小的十个数所在位置。
11行用乘号,输出放在循环里。
#include <iostream> using namespace std; int main() { int a[10]; for (int i = 0; i < 10; i++) { a[i] = rand() % 20 + 1; cout << a[i] << " "; } }