-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathB11.PAS
More file actions
57 lines (57 loc) · 1.16 KB
/
B11.PAS
File metadata and controls
57 lines (57 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
program B11;
uses crt;
type
arr = array[1..100] of longint;
var
x,i,j,t,n,cnt,m,s:longint;
a : arr;
function Hecxa(b:longint):arr;
var
s,r,i,p : Longint;
ar : arr;
begin
cnt := 0;
i := 0;
s := 0;
while b > 0 do
begin
r := b mod 16;
b := b div 16;
inc(cnt);
ar[cnt] := r;
end;
for i := 1 to cnt do
Hecxa[i] := ar[cnt-i+1];
end;
begin
clrscr;
repeat
write('nhap x : ');readln(x);
until (x >= 1) and (x <= 1000000000);
a := Hecxa(x);
n := cnt;
for i:= 1 to n do
write(a[i]);
writeln;
for i := 1 to n-1 do
for j := i+1 to n do
if a[i] < a[j] then
begin
t := a[i];
a[i] := a[j];
a[j] := t;
end;
s := 0;
m := 1;
for i:=1 to n do
write(a[i]);
writeln;
for i := n downto 1 do
begin
{writeln(m,' * ',b[i],' = ',b[i]*m);}
s := s + a[i]*m;
m := m * 16;
end;
writeln(s);
readln;
end.