Сделал 22 Задание Массивов

This commit is contained in:
AZEN-SGG 2024-10-09 15:51:25 +03:00
parent c3182c8c24
commit 5852a9f034
23 changed files with 99 additions and 31 deletions

View file

@ -0,0 +1,18 @@
#include "replace_local_min.h"
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 (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);
return final_num;
}