发布时间:2019-07-29 17:22:24
/*a[1] = 36a[7] = 38a[3] = 13a[6] = 95a[8] = 54Press any key to continue*/#include <stdio.h>#include <stdlib.h>#include <time.h>int main() {int a[10] = {12,36,52,13,30,87,95,38,54,19};int b[10] = {0}; // 全部初始化为0int i,t,n = 10,m = 5;srand((unsigned)time(NULL));for(i = 0; i < m; ++i) { // 随机显示5个数组元素t = rand()%n;if(b[t] == 0) {b[t] = 1;printf("a[%d] = %d\n",t,a[t]);}else i--;}return 0;}