回覆列表
  • 1 # 小紅的甜心

    #include <stdio.h>

    #include <time.h>

    #include <stdlib.h>

    unsigned int seed = (unsigned int)time(0);

    int a[1111];

    int main() {

    int i;

    double aver = 0;

    FILE* f1 = fopen("in.txt", "w");

    for (i = 1; i <= 100; i++) {

    srand(seed++);

    int v = rand() % 1001;

    a[i] = v;

    fprintf(f1, "%d ", v);

    aver += v;

    }

    aver /= 100;

    int tv = 1;

    fclose(f1);

    FILE* f2 = fopen("out.txt", "w");

    for (i = 1; i <= 100; i++) {

    if (a[i] > aver) {

    fprintf(f2, "%d ", a[i]);

    if (tv++ % 5 == 0) {

    fprintf(f2, "\n");

    }

    }

    }

    fclose(f2);

    return 0;

    }

  • 中秋節和大豐收的關聯?
  • 仙劍奇俠傳3徐長卿和景天進入神魔之井後的劇情?