Polnochniy

Untitled

Nov 21st, 2019
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. const int N = 7;
  4. using namespace std;
  5. int main()
  6. {
  7. setlocale(LC_ALL, "Rus");
  8. int a[N], i;
  9. int min = 0;
  10. cout << "Введите элементы массива . Найти минимальный нечетный элемент ";
  11. for (i = 0; i < N; i++)
  12. {
  13. cin >> a[i];
  14. }
  15. for (int i = 0; i < N; i++)
  16. {
  17. if (a[i] % 2 != 0)
  18. {
  19. min = a[i];
  20. }
  21. }
  22. for (int i = 0; i < N; i++)
  23. {
  24. if (a[i] % 2 != 0 && a[i] < min)
  25. {
  26. min = a[i];
  27.  
  28. }
  29. }
  30. cout << "Наименьший нечетный элемент массива: " << min << endl;
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment