Сделал 13 усовершенствованную с иным заданием

This commit is contained in:
AZEN-SGG 2024-10-18 10:00:53 +03:00
parent 5852a9f034
commit 3f5c6299fc
11 changed files with 146 additions and 5 deletions

View file

@ -1,18 +1,25 @@
#include "replace_local_min.h"
double min(double * numbers) {
for (int i = 1; i < length; ++i) {
}
}
int replaceLocalMin(double * numbers) {
int length = numbers[0];
unsigned final_num = 1;
unsigned local_length = 1;
for (int i = 2; i < length; ++i, ++final_num) {
if (numbers[i - 1] == numbers[i]) { if (local_length) ++local_length;
} else if (numbers[i - 1] < numbers[i]) {
if (fabs(numbers[i - 1] - numbers[i]) < exp) { if (local_length) ++local_length;
} else if ((numbers[i] - numbers[i - 1]) > exp) {
if (local_length) final_num -= (local_length - 1), local_length = 0;
} else local_length = 1;
}
if ((numbers[length - 1] == numbers[length - 2]) && (local_length)) final_num -= (local_length - 1);
if ((fabs(numbers[length - 1] - numbers[length - 2]) < exp) && (local_length)) final_num -= (local_length - 1);
return final_num;
}