Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program systemy;
- uses crt,math;
- var
- system_wejscie,system_wyjscie,liczba,j,i,reszta:integer;
- tab,wynik,znak:string;
- begin
- write ('wprowadz w jakim systemie wprowadzasz liczbe: ');
- readln (system_wejscie);
- write ('wpisz liczbe: ');
- readln (tab);
- j:=0;
- liczba:=0;
- for i:=Length(tab) downto 1 do
- begin
- if (ord(tab[i])<ord('A')) then
- begin
- liczba:=round(liczba+(ord(tab[i])-48)*power(system_wejscie,j));
- end;
- if (ord(tab[i])>=ord('A')) then
- begin
- liczba:=round(liczba+(ord(tab[i])-ord('A')+10)*power(system_wejscie,j));
- end;
- j:=j+1;
- end;
- write('W jakim chcesz wyprowadzic:') ;
- readln (system_wyjscie);
- repeat
- reszta:=liczba mod system_wyjscie;
- if(reszta=10) then
- znak:='A' else if(reszta = 11) then
- znak:='B' else if(reszta = 12) then
- znak:='C' else if(reszta = 13) then
- znak:='D' else if(reszta = 14) then
- znak:='E' else if(reszta = 15) then
- znak:='F' else str(reszta,znak); // zmiana reszta (int na string) i podstawienie w zmiennej znak
- insert(znak,wynik,1); // umieszczenie znak w stringu wynik na poz 1
- liczba:=liczba div system_wyjscie;
- until(liczba=0) ;
- writeln(wynik);
- readkey;
- end.
Advertisement
Add Comment
Please, Sign In to add comment