Var m : array[0..6] of Integer; i,k,N : Integer; Begin For i:=0 to 6 do m[i]:=0; Readln(N); k:=6; While N>0 do Begin If N>=Power(2,k) then Begin N:=N-Trunc(Power(2,k)); Inc(m[k]); end else Dec(k); end; For i:=0 to 6 do Writeln(Power(2,i),' ',m[i],' шт.'); end.
Еще вариант: Const NN = 7; money : array[1..7] of Integer = (1,2,4,8,16,32,64); Var m : array[1..NN] of Integer; i,k,N : Integer; Begin For i:=1 to NN do m[i]:=0; Readln(N); k:=NN; While N>0 do Begin If N>=money[k] then Begin N:=N-money[k]; Inc(m[k]); end else Dec(k); end; For i:=1 to NN do Writeln(money[i],' ',m[i],' шт.'); end.
//Я просто опишу метод записи матрицы const n=100; var ar:array of array of integer; ars:array of array of string; i:integer;
procedure complection(var ar:array of array of integer;var ars:array of array of string); var i,j:integer; begin; for i:=1 to n do begin; for j:=1 to n do begin; ar[i,j]:=random(9); str(ar[i,j],ars[i,j]); end; end; end;
procedure burning(ars:array of array of string); var i,j:integer; t:text; begin; assign(t,'text.txt'); rewrite(t); for i:=1 to n do begin; writeln(t,' '); for j:=1 to n do write(t,ars[i,j],' '); end; end;
begin; randomize; setlength(ar,n+1); setlength(ars,n+1); for i:=1 to n do begin; setlength(ar[i],n+1); setlength(ars[i],n+1); end; complection(ar,ars); burning(ars); end.
i,k,N : Integer;
Begin
For i:=0 to 6 do m[i]:=0;
Readln(N);
k:=6;
While N>0 do
Begin
If N>=Power(2,k) then
Begin
N:=N-Trunc(Power(2,k));
Inc(m[k]);
end else Dec(k);
end;
For i:=0 to 6 do Writeln(Power(2,i),' ',m[i],' шт.');
end.
Еще вариант:
Const
NN = 7;
money : array[1..7] of Integer = (1,2,4,8,16,32,64);
Var m : array[1..NN] of Integer;
i,k,N : Integer;
Begin
For i:=1 to NN do m[i]:=0;
Readln(N);
k:=NN;
While N>0 do
Begin
If N>=money[k] then
Begin
N:=N-money[k];
Inc(m[k]);
end else Dec(k);
end;
For i:=1 to NN do Writeln(money[i],' ',m[i],' шт.');
end.
const n=100;
var ar:array of array of integer;
ars:array of array of string;
i:integer;
procedure complection(var ar:array of array of integer;var ars:array of array of string);
var
i,j:integer;
begin;
for i:=1 to n do
begin;
for j:=1 to n do
begin;
ar[i,j]:=random(9);
str(ar[i,j],ars[i,j]);
end;
end;
end;
procedure burning(ars:array of array of string);
var
i,j:integer;
t:text;
begin;
assign(t,'text.txt');
rewrite(t);
for i:=1 to n do
begin;
writeln(t,' ');
for j:=1 to n do
write(t,ars[i,j],' ');
end;
end;
begin;
randomize;
setlength(ar,n+1);
setlength(ars,n+1);
for i:=1 to n do
begin;
setlength(ar[i],n+1);
setlength(ars[i],n+1);
end;
complection(ar,ars);
burning(ars);
end.