#include #include using namespace std;//通过随机数发生器,产生cardnum(1~100之间的数)int main(){ int seed, cardnum; cout << "Enter a random seed: "; cin >> seed; srand(seed); for (int i = 0; i < 15; i++) { cardnum = rand() % 101; } int a = cardnum; int max, i, j, t; for (j = 9; j > 0; j--) { max = j; for (i = 0; i <= j; i++) { if (a[i] > a[max]) { max = i; } } if (j != max) { t = a[max]; a[max] = a[j]; a[j] = t; } } //输出排序结果 for (int i = 0; i < 10; i++) { cout << a[i] << endl; return 0;}
你这个a也不是数组或者指针之类的,怎么能用a[]呢