Это код калькулятора(Паскаль),нужно,чтобы он был написан по столбикам,а не по строчкам,как сейчас.
program Calculator;
uses Functions,GrMouse,GrButton,Graph,GrOutPut,dos,crt;: string=' 7 8 9/< - x^y'+
' 4 5 6 * sin cos'+
' 1 2 3 - tg ktg'+
' 0 с. + = ы'+
' P R O E K T';
{$F+}: array [1.35] of TGrButton;,QuitButton: TGrButton;,SecondEdit: TGrButton;: TMouseStatus;: boolean;GetCaption (i: byte): string;,TempPos,Count: byte;: =0;: =0;x: =1 to Length (Captions) doCaptions [x] =' ' then inc (count);Count=i-2 then TempPos: =x;Count=i-1 then GetCaption: =copy (Captions,TempPos+2,x-TempPos-1);;;ChangeSysOfCount (SysOfCount: TSysCountStr);: string;SysOfCount [1] of
'D': begin;;SysOfCount [1] of
'D': begin SysCount: =DEC; DisButtons: =DECindexes; end;;(FParam);(SParam);(false);(SParam);(true);(FParam);;SetGroupEnabled (SysOfCount: TSysCountStr);: =ALLnumbers;i: =2 to 35 doi in DisButtons thenButtons [i] donot Enabled then(true);(SysOFCount);i: =2 to 35 doi in DisButtons then[i]. SetEnabled (False);: ='';;DrawingSquareOfButt (MaxTopInc,LeftOffs,TopOffs,BStartInd,BCount: word);: =0;j<=MaxTopInc doi: =BStartInd-1 to BStartInd+BCount-2 do[j+i+1]. Left: =i*50+LeftOffs;[j+i+1]. Top: =j*7+TopOffs;[j+i+1]. Draw;;(j,7);;;Action;: =true;;SetRadioClick (var ActButt,DisAct1,DisAct2: TGrButton);ActButt. FillColor=ActButt. FillColor then. FillColor: =ActButt. PressedColor;. FillColor: =1;. FillColor: =1;. Fill (ActButt. PressedColor);. Fill (DisAct1. FillColor);. FIll (DisAct2. FillColor);;;SetDECsys;(Buttons [8],Buttons [1],Buttons [15]);('DEC');;FstAction;(FirstEdit. FillColor=1) then. FillColor: =4;. FillColor: =1;. Draw;. Draw;(true);: =false;;;SndAction;(SecondEdit. FillColor=1) then. FillColor: =1;. FillColor: =4;. Draw;. Draw;(false). Init;. Init;. Init;. Init;i: =1 to 35 doButtons [i] do;: =GetCaption (i+1);;QuitButton do: =140;: =GetMaxY-50;: =20;: =370;: ='Quit';;;CEButton do: =GetMaxX-220;: =80;: =30;: =85;: ='CE';;;FirstEdit do: =GetMaxX-55;: =120;: ='Fst';: =4;;;SecondEdit do: =GetMaxX-55;: =170;: ='Snd';;;(30,140,1200,1,1);(30,170,120,2,6);(5,5,GetMaxX-5,GetMaxY-5);(OutXs,OutYs,OutXf,OutYf);
{/*End of drawing*/};;;[1]. PressedColor: =8;[8]. PressedColor: =8;[15]. PressedColor: =8;('DEC');(Buttons [8],Buttons [1],Buttons [15]);[8]. Action: =SetDECsys;[6]. Action: =BackSpaceSymbol;[24]. Action: =SetPlusMines;[27]. Action: =GetResult;
{}not Quit doi: =1 to 35 doButtons [i] doonClick (Action,MouseStatus) then(Length (Caption) =1) then(Caption [1] in SysCount) then(Caption);: =false;;(Caption [1]);Caption [1] ='с' then Calculated: =false;;: =0;KeyPressed then: =Ord (readkey);Key of
.57,46,97.103:UpCase (Char (Key)) in SysCount then(UpCase (Char (Key)));: =false;;
: begin;: =false;;
: SetEnterMode ('*'); {*}
: SetEnterMode ('+'); {+}
: SetEnterMode ('-'); {-}
: SetEnterMode ('/'); {/}
: exit. onClick (Action,MouseStatus);. OnClick (CEClick,MouseStatus);FirstEdit. OnClick (FstAction,MouseStatus) or (FActive) then FstAction;SecondEdit. OnClick (SndAction,MouseStatus) or (SActive) then SndAction;;;.
a) 5 * 2 - 4
Решение:
Умножение имеет более высокий приоритет, чем вычитание. Поэтому, сначала выполним вычисление умножения: 5 * 2 = 10.
Затем, выполним вычитание: 10 - 4 = 6.
Ответ: 6.
б) 7 * х + 2
Решение:
Умножение имеет более высокий приоритет, чем сложение. Поэтому, сначала выполним вычисление умножения: 7 * х = 7х.
Затем, выполним сложение: 7х + 2.
Ответ: 7х + 2.
в) 8 * х - 3 * (х + у)
Решение:
Выполним умножение: 8 * х = 8х и 3 * (х + у) = 3х + 3у.
Затем, выполним вычитание: 8х - (3х + 3у).
Для выполнения операции в скобках, умножение 3 на каждый из элементов внутри скобок:
8х - 3х - 3у = 5х - 3у.
Ответ: 5х - 3у.
г) v^2 * х * у^2 * х * у
Решение:
По правилам алгебры, умножение можно проводить в любом порядке.
Выполним умножение: v^2 * х = v^2х, у^2 * х = у^2х, v^2х * у^2х = (vх * у)^2х.
Ответ: (vх * у)^2х.
2. Переведем запись с языка Pascal в нормальную форму:
f = (3 * x + 4 * y)/(2 * sqr(к) - 4 * t / y)
Решение:
Нормализация выражения подразумевает разделение на более простые составляющие.
Заменим sqr(к) на к^2, чтобы выразить возведение в квадрат в общепринятой форме:
f = (3 * x + 4 * y)/(2 * к^2 - 4 * t / y)
Затем, выполним умножение и деление в числителе и знаменателе:
f = (3 * x + 4 * y)/(2к^2 - (4 * t) / y)
Ответ: f = (3 * x + 4 * y)/(2к^2 - 4t/y).
Таким образом, мы записали выражения по правилам языка Pascal и перевели запись с языка Pascal в нормальную форму.