InfLab2/prog1.c
2024-11-30 12:51:43 +04:00

29 lines
633 B
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <stdio.h>
#include <stdlib.h>
#include "progs.h"
#include "arrays.h"
void prog1(){
int arr[_ARR_SIZE]; fill_array(arr);
int index = -1;
int value = 0;
for(int i = 0; i < _ARR_SIZE; i++){
if(arr[i]<value && arr[i]<0 && (arr[i]&1)==0){
index = i;
value = arr[i];
}
}
#if _ARR_SIZE <= 10
print_array(arr);
print_pointer(index);
#endif
if(index>=0){
printf("Минимальный чётный отрицательный элемент равен %d\n", value);
} else{
printf("В массиве нет ни одного элемента, подходящего под условия\n");
}
}