procedure MassivSort(var arr : array of Real; const N : Integer);var I: Integer; J: Integer; K: Integer; M: Real;begin for i:=1 to N do begin m:=Arr[i-1]; k:=i; for j:=i to n do begin if m>Arr[j-1] then begin m:=Arr[j-1]; k:=j; end; end; Arr[k-1]:=Arr[i-1]; Arr[i-1]:=m; end;end;
Сортировка по убыванию:
procedure sort; var i , j , tmp : integer; begin for i := 1 to n - 1 do for j := i + 1 to n do if a[i] < a[j] then begin tmp := a[i]; a[i] := a[j]; a[j] := tmp; end;
#include <iostream>
#include <string>
using namespace std;
void plus1(char*,int*);
int main(void)
{string n;
char poli[108];
int kar=0,buf,add=0;
cin>>n;
for(int i=0;i<n.length()/2+n.length()%2;i++)
{poli[kar]=n[i];
kar++;}
buf=kar;
plus1(poli,&kar);
if(buf!=kar)
{add++;
buf=kar;}
if((n.length()+add)%2!=0)
for(int i=buf-2;i>=0;i--)
{poli[kar]=poli[i];
kar++;}
else
for(int i=buf-1;i>=0;i--)
{poli[kar]=poli[i];
kar++;}
for(int i=0;i<kar;i++)
cout<<poli[i];
return 0;}
void plus1(char slogaem[],int* len)
{int add=1;
for(int i=*len-1;i>=0;i--)
if(slogaem[i]=='9' && add==1)
{add=1;
slogaem[i]='0';}
else
{slogaem[i]+=add;
add=0;}
if(slogaem[0]=='0' && add==1)
{for(int i=*len;i>0;i--)
slogaem[i]=slogaem[i-1];
slogaem[0]='1';
*len+=1;}}
Пример ввода:
93439
Пример вывода:
93539
procedure MassivSort(var arr : array of Real; const N : Integer);var I: Integer; J: Integer; K: Integer; M: Real;begin for i:=1 to N do begin m:=Arr[i-1]; k:=i; for j:=i to n do begin if m>Arr[j-1] then begin m:=Arr[j-1]; k:=j; end; end; Arr[k-1]:=Arr[i-1]; Arr[i-1]:=m; end;end;
Сортировка по убыванию:
procedure sort;
var i , j , tmp : integer;
begin
for i := 1 to n - 1 do
for j := i + 1 to n do
if a[i] < a[j] then begin
tmp := a[i];
a[i] := a[j];
a[j] := tmp;
end;