Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program rozklad;
- uses crt;
- const
- n = 2000;
- var
- tabC : array [1..n] of longint;
- tabIter,codeBl : integer;
- a,kL : longint;
- ok,zle : byte;
- wybor,l : string;
- label zlaLiczba,zeroLubJeden;
- begin
- wybor:='1';
- REPEAT
- zlaLiczba:
- clrscr;
- write('Podaj liczbe: ');readln(l);
- val(l,kL,codeBl);
- if(codeBl<>0) then begin clrscr;goto zlaLiczba;end;
- write('Rozklad ',l,' na czynniki: ');
- if l='1' then write('1');
- if l='0' then write('0');
- if (l='0') OR (l='1') then goto zeroLubJeden;
- tabIter:=0;
- REPEAT
- a:=2;
- ok:=0;
- zle:=0;
- REPEAT
- if zle=1 then begin
- a:=a+1;
- zle:=0;
- end;
- if (kL mod a = 0) then begin
- inc(tabIter);
- tabC[tabIter]:=a;
- kL:=kL div a;
- ok:=1;
- end ELSE zle:=1;
- UNTIL (ok=1) OR (a=kL);
- UNTIL kL=1;
- if sizeof(tabC)>0 then begin
- for a:=1 to n do begin
- if tabC[a]=0 then continue;
- write(tabC[a]);
- if tabC[a+1]<>0 then write(', ');
- tabC[a]:=0;
- end;
- end;
- zeroLubJeden:
- writeln;
- write('Nacisnij dowolny klawisz');
- readkey;clrscr;
- writeln('1 - rozloz inna liczbe na czynniki');
- writeln('2 - zakoncz');
- write('Podaj: ');REPEAT readln(wybor);UNTIL (wybor[1]='1') OR (wybor[1]='2');
- UNTIL wybor='2';
- end.
Advertisement
Add Comment
Please, Sign In to add comment