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

28 lines
597 B
C
Raw 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 prog2(){
int arr[_ARR_SIZE]; fill_array(arr);
int index = -1;
for(int i = 0; i < _ARR_SIZE; i++){
if(arr[i] > 0 && (arr[i]&1)==0){
index = i;
break;
}
}
#if _ARR_SIZE <= 10
print_array(arr);
print_pointer(index);
#endif
if(index>=0){
printf("Первый положительный чётный элемент имеет индекс %d\n", index);
} else{
printf("В массиве нет ни одного элемента, подходящего под условия\n");
}
}