Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program konwerter2;
- var
- a, b, c, d, i, x, e, q : integer;
- g : char;
- tab1 : array [1..100] of integer; //wynik w systemach 2-10
- tab2 : array [1..100] of char; //wynik w systemach 11-16
- tab3 : array [1..100] of char; //liczba w systemie 11-16
- Procedure z10naDowolny; {konwersja liczby z systemu dziesiętnego na dowolny z zakresu 2-16}
- begin
- Write('Podaj liczbe w systemie 10: ');
- readln(a);
- Write('Podaj podstawe systemu, na ktory chcesz zamienic liczbe(od 2 do 16): ');
- readln(b);
- c:=a;
- i:=1;
- Case b of
- 2..10 : begin { Z dziesiętnego na 2 do 10 }
- Repeat
- d := c mod b;
- tab1[i]:=d;
- e := c div b;
- i:=i+1;
- c := e;
- until c<=0
- end;
- 11..16 : begin {11-16}
- Repeat
- d := c mod b;
- Case d of
- 0: g:='0';
- 1: g:='1';
- 2: g:='2';
- 4: g:='4';
- 5: g:='5';
- 6: g:='6';
- 7: g:='7';
- 8: g:='8';
- 9: g:='9';
- 10: g:='A';
- 11: g:='B';
- 12: g:='C';
- 13: g:='D';
- 14: g:='E';
- 15: g:='F';
- end;
- tab2[i]:=g;
- e := c div b;
- i:=i+1;
- c := e;
- until c<=0
- end;
- end;
- write('Liczba ',a,' w systemie o podstawie ',b,' to: ');
- i:=i-1;
- Case b of
- 2..10 : begin
- For x:=i downto 1 do
- begin
- write(tab1[i]);
- i:=i-1;
- end;
- end;
- 11..16 : begin
- For x:=i downto 1 do
- begin
- write(tab2[i]);
- i:=i-1;
- end;
- end;
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement