回复 10楼 pangshch
这个问题我已经明白了,但是这个程序是错误的,原题是这样的:用C语言如何编程实现从三个数组中各抽取几个数进行组合的问题?
例:从数组A中抽取3个数,数组B中抽取2个数,数组C中抽取1个数,组成6个数的组合,求源程序。
A={3,4,6,7,8,9,11,13,14,15,16,18,19,20,24,27,28,29,33}
B={1,2,10,12,17,21,22,25,26,30,31,32}
C={5,23}
#include <stdio.h> #include <time.h> #include <stdlib.h> int main() { int A[19]={3,4,6,7,8,9,11,13,14,15,16,18,19,20,24,27,28,29,33}; int B[12]={1,2,10,12,17,21,22,25,26,30,31,32}; int C[2]={5,23}; int i, j, k = 0; int T[6]; srand(time(NULL)); for (i = 0; i < 3; i++) { j = rand()%19; T[k++] = A[j]; } for (i = 0; i < 2; i++) { j = rand()%12; T[k++] = B[j]; } j = rand()%2; T[k++] = C[j]; for (i = 0; i < 6; i++) printf("%d ", T[i]); printf("\n"); return 0; }