int CreatMatrix(int *matrix) { int i,j; int buf; for(i=0;i<9;i++) { getElem: srand((unsigned)time(NULL)); buf=rand()%9; for(j=0;j<i;j++) { if(matrix[j]==buf) goto getElem; } matrix[i]=buf; } return OK; }
转载于:https://www.cnblogs.com/android-html5/archive/2011/05/11/2533701.html