#include #include void print_arr (int* a, int n){ int i = 0; for (; i < n; ++i) { printf ("%d ", a[i]); if ((i+1) % 10 == 0) { printf("\n"); } } printf("\n");} #define N 50int main(int argc, char** argv){ srand(time(NULL)); // 设置当前时间为随机数种子 int a[N], i; for (i = 0; i < N; i++) { a[i] = rand() % 100 + 100; } print_arr(a, N); return 0;}
运行:
回答2:
#include #include #include #define N 50 void main() { int a[N],n=N,i,j; srand((unsigned int)time(NULL)); for ( j=0;j for ( j=0;j scanf("%d",&i); n--; for ( j=i;j for ( j=0;j}