furs1975
Uses crt;var a,b:array [1..50] of integer; i,j,n,min:integer;begin clrscr; j:=1; for i:=1 to 10 do begin write('a[',i,']='); readln(a[i]); if (a[i] mod 2)<>0 then begin b[j]:=a[i]; j:=j+1; end; end; min:=b[1]; for n:=1 to j-1 do begin if b[n]<min then min:=b[n]; end; write('Наименьший нечетный элемент=',min); end.
Answers & Comments
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
int main()
{
vector<int> v(50);
srand(time(0));
cout <<"Массив:" <<endl;
int min;
for(auto it=v.begin(); it!=v.end(); ++it)
{
*it=rand()%101-50;
if(*it%2!=0) min=*it;
cout <<*it <<" ";
}
cout <<endl;
for(auto it=v.begin(); it!=v.end(); ++it)
if((*it<min) && (*it%2!=0)) min=(*it);
cout <<"Минимальный элемент: " <<min <<endl;
return 0;
}