2024-11-27 20:38:57 +04:00
|
|
|
|
#define _CRT_SECURE_NO_WARNINGS
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <Windows.h>
|
2024-11-14 12:15:33 +04:00
|
|
|
|
|
2024-11-27 20:38:57 +04:00
|
|
|
|
int a[1000];
|
|
|
|
|
int n;
|
2024-11-14 12:15:33 +04:00
|
|
|
|
|
2024-11-27 20:38:57 +04:00
|
|
|
|
void Load() {
|
|
|
|
|
FILE* fin = fopen("C:\\Users\\Admin\\Desktop\\Лабы ОАиП\\массивы\\19.txt", "rt");
|
|
|
|
|
if (fin == NULL) {
|
|
|
|
|
printf("Входной файл не найден\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fscanf(fin, "%d", &n);
|
|
|
|
|
for (int i = 0; i < n; i++) {
|
|
|
|
|
fscanf(fin, "%d", &a[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fclose(fin);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SaveResult() {
|
|
|
|
|
float sa = 0;
|
|
|
|
|
float s = 0;
|
|
|
|
|
for (int i = 0; i < n; i++) {
|
|
|
|
|
s += a[i];
|
|
|
|
|
}
|
|
|
|
|
sa = s / n;
|
|
|
|
|
|
|
|
|
|
int m = 0;
|
|
|
|
|
for (int i = 0; i < n; i++) {
|
|
|
|
|
if (a[i] > sa) {
|
|
|
|
|
m++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
FILE* fout = fopen("C:\\Users\\Admin\\Desktop\\Лабы ОАиП\\массивы\\191.txt", "wt");
|
|
|
|
|
if (fout == NULL) {
|
|
|
|
|
printf("Выходной файл не найден\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Сохранение элементов больших ср арифметического
|
|
|
|
|
fprintf(fout, "%d\n", m);
|
|
|
|
|
for (int i = 0; i < n; i++) {
|
|
|
|
|
if (a[i] > sa) {
|
|
|
|
|
fprintf(fout, "%d ", a[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Закрытие файла
|
|
|
|
|
fclose(fout);
|
|
|
|
|
}
|
|
|
|
|
void main() {
|
|
|
|
|
SetConsoleCP(1251);
|
|
|
|
|
SetConsoleOutputCP(1251);
|
|
|
|
|
printf("Hello! It is Task1!\n");
|
|
|
|
|
|
|
|
|
|
Load();
|
|
|
|
|
|
|
|
|
|
SaveResult();
|
2024-11-14 12:15:33 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|