
Program ToDec;
Uses crt;
var s:string;
n,l,i:integer;
function Pow(x,y:integer):integer;
begin
if y>0 then Pow:=Pow(x,y-1)*x
else Pow:=1;
end;
function ToDec(A : string) : integer;
var L : Byte;
begin
if A = '' then ToDec := 0
else begin
L := length(A);
case A[1] of
'0' : ToDec := ToDec(Copy(A, 2, L - 1));
'1' : ToDec := Pow(2, L - 1) + ToDec(Copy(A, 2, L - 1));
end;
end;
end;
begin
clrscr;
write('Введите двоичное число: ');
readln(s);
writeln('Это число в десятичной системе : ', ToDec(S));
readkey;
end.
1.
#include <iostream>
#include <vector>
using namespace std;
int main(){
int a,b;
cin>>a;
vector<int> v1;
vector<int> v2;
for(int i=0; i<a; i++){
cin>>b;
if (b%2==0) v1.emplace_back(b);
else v2.emplace_back(b);
}
sort(v1.begin(), v1.end());
sort(v2.begin(), v2.end());
for(auto & i: v1) cout<<i<<" ";
}
2.
#include <iostream>
#include <vector>
using namespace std;
int main(){
vector<float> v;
//здесь нам задают массив
sort(v.begin(), v.end());
cout<<v[0]<<v.back();
}