Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program project1;
- uses
- crt, DOS;
- const Digits: String='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
- function AnyToDec(inputString: String; numberSystem: Integer): Int64;
- var
- X, i: Integer;
- begin
- Result := 0;
- for i := 1 to Length(inputString) do
- begin
- X := Pos(inputString[i], Digits) - 1;
- Result := Result*numberSystem + X;
- end;
- end;
- function DecToAny(input: Int64; numberSystem: Integer): String;
- var
- X: Integer;
- begin
- Result := '';
- repeat
- X := input mod numberSystem;
- input := input div numberSystem;
- Result := Digits[X + 1] + Result;
- until (input = 0) ;
- end;
- var
- inputSystem, outputSystem: Int64;
- inputValue: String;
- begin
- write('system z ktorego bedziesz konwertowal: ');
- readLn(inputSystem);
- write('system do ktorego bedziesz konwertowal: ');
- readLn(outputSystem);
- write('Wprowadz liczbe do konwersji w systemie z ktorego chcesz konwertowac: ');
- readLn(inputValue);
- writeln( DecToAny( AnyToDec( inputValue, inputSystem ), outputSystem ) );
- ReadKey;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement