Ответ: Наче так
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define N 14
int main()
{
int F[N];
int i, j, min, max, min_i, max_i, temp;
srand(time(NULL));
for (i = 0; i < N; i++)
F[i] = rand() % 100;
printf("%d ", F[i]);
}
printf("\n");
min = F[0];
max = F[0];
if (F[i] < min)
min = F[i];
min_i = i;
if (F[i] > max)
max = F[i];
max_i = i;
temp = F[0];
F[0] = min;
F[min_i] = temp;
temp = F[N - 1];
F[N - 1] = max;
F[max_i] = temp;
return 0;
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Ответ: Наче так
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define N 14
int main()
{
int F[N];
int i, j, min, max, min_i, max_i, temp;
srand(time(NULL));
for (i = 0; i < N; i++)
{
F[i] = rand() % 100;
printf("%d ", F[i]);
}
printf("\n");
min = F[0];
max = F[0];
for (i = 0; i < N; i++)
{
if (F[i] < min)
{
min = F[i];
min_i = i;
}
if (F[i] > max)
{
max = F[i];
max_i = i;
}
}
temp = F[0];
F[0] = min;
F[min_i] = temp;
temp = F[N - 1];
F[N - 1] = max;
F[max_i] = temp;
for (i = 0; i < N; i++)
{
printf("%d ", F[i]);
}
printf("\n");
return 0;
}