#include
main()
{
int x, s=0, n=0;
float sr;
FILE *fin, *fout;
fin = fopen("input.txt", "r");
fout = fopen("output.txt", "w");
while (fscanf(fin, "%d", &x) == 1) {
s+=x;
n++;
}
sr = 1.0*s/n;
fclose (fin);
fin = fopen("input.txt", "r");
while (fscanf(fin, "%d", &x) == 1) {
if (x < sr) x = 0;
fprintf (fout, "%d ", x);
}
fclose (fout);
fclose (fin);
}
Пример:
Файл input.txt:
21 45 87 61 90 43 70 15 33 58
Файл output.txt:
0 0 87 61 90 0 70 0 0 58