Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- const int N = 7;
- using namespace std;
- int main()
- {
- setlocale(LC_ALL, "Rus");
- int a[N], i;
- int min = 0;
- cout << "Введите элементы массива . Найти минимальный нечетный элемент ";
- for (i = 0; i < N; i++)
- {
- cin >> a[i];
- }
- for (int i = 0; i < N; i++)
- {
- if (a[i] % 2 != 0)
- {
- min = a[i];
- }
- }
- for (int i = 0; i < N; i++)
- {
- if (a[i] % 2 != 0 && a[i] < min)
- {
- min = a[i];
- }
- }
- cout << "Наименьший нечетный элемент массива: " << min << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment