Технический форум

Технический форум (http://www.tehnari.ru/)
-   Помощь студентам (http://www.tehnari.ru/f41/)
-   -   Создайте блок-схему (http://www.tehnari.ru/f41/t73207/)

icewind 15.05.2012 22:04

Создайте блок-схему
 
Var
m0,m,Max_W,i,counter,q:Integer;
f:Text;
Res:Array[1..20] of ShortInt;

Function Pw3(v:byte):LongInt;
var
t:byte;
P:LongInt;
begin
if v=0 then P:=1 else
begin
P:=1;
for t:=1 to v do P:=P*3;
end;
Pw3:=P;
end;

Begin
Assign(f,'Input.txt');
Reset(f);
Readln(f,m0,Max_W);
Close(f);
m:=m0;
counter:=0;
Repeat
q:=m mod 3;
if q=2 then q:=-1;
Inc(counter);
If counter<=Max_W then
Res[counter]:=q;
m:=m div 3;
if q=-1 then m:=m-q;
Until (q=1) and (counter>1);
Write(m0,' = ');
If counter<=Max_W then
For i:=counter downto 1 do
if i=counter then write(Pw3(i-1)) else
if Res[i]=-1 then write(Pw3(i-1)*Res[i]) else
write('+',Pw3(i-1)*Res[i]);
Assign(f,'Output.txt');
Rewrite(f);
If counter>Max_W then
writeln(f,'No solution!') else
begin
write(f,m0);
for i:=1 to counter do
if Res[i]=-1 then write(f,' ',Pw3(i-1));
writeln(f);
for i:=1 to counter do
if Res[i]=1 then write(f,' ',Pw3(i-1));
end;
Close(f);
Readln;
End.

Léon 16.05.2012 23:16

Цитата:

Сообщение от icewind (Сообщение 732947)
Создайте блок-схему

Точно такая же программа и к ней сделана блок-схема, вот.


Часовой пояс GMT +4, время: 07:10.

Powered by vBulletin® Version 4.5.3
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.