#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<Windows.h>
#include<time.h>
int main(void) {
srand(time(NULL));
int randomy,m;
int numy[50];
m = rand() % 20 + 10;
int count1, count2, count3=1,count4;
for (count1 = 1; count1 <= m; count1++) {
randomy = rand() % m + 1;
if (randomy % 2 == 0) {
numy[count3] = randomy;
count3++;
}
}//获取并储存随机数组
int i;
for (i = 1; i < count3; i++) {
printf("%d\n", numy[i]);
}
}
输出结果:
yesyes