#include <stdio.h>
#include <stdlib.h>
int Simple(int N)
{
for (int i = 2; i*i <= N; i++)
if (N % i == 0) return 0;
return 1;
}
int main() {
FILE *S1;
int i, j, *a, n, sr_zn;
system("chcp 1251");
system("cls");
S1 = fopen("input.txt", "r");
fscanf(S1, "%d", &n);
a = (int*)malloc(n * sizeof(int));
sr_zn = 0;
for (int i = 0; i < n; i++)
{
fscanf(S1, "%d", &a[i]);
sr_zn += a[i];
}
sr_zn = sr_zn / n;
i = 0;
j = 0;
while (i < n)
{
if (j < n)
{
if (a[j] > sr_zn && Simple(a[j]))
{
a[i] = a[j];
i++;
}
j++;
}
else {
a[i] = 0;
i++;
}
}
for (int i = 0; i < n; i++)
{
printf( "%d ", a[i]);
}
fclose(S1);
getchar(); getchar();
return 0;
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.