Anonymous Anonymous - 1 month ago
93 1

No description

Pascal

Bases

(*Base2T036----------------------------------------Simon Aichinger*)
(*07.11.2016------------------------------------------------------*)
(*Beschreibung----------------------------------------------------*)
(*================================================================*)

Program Base;
  USES math;


FUNCTION DigVal(digits: CHAR): INTEGER;
  VAR
    BetVal: INTEGER;
    i: INTEGER;
BEGIN
digits := digits[i];
BetVal := Ord(digits);
DigVal := Betval;
END;

FUNCTION ValueOf(digits: STRING; base: INTEGER): INTEGER;

  VAR 
    i: INTEGER;
    ConVal: INTEGER;
    
BEGIN
ConVal := 0;
  FOR i := 1 TO Length(digits) DO BEGIN
    ConVal:= ConVal + ((DigVal(digits[i])  * (base ** BetVal));
  END;
  ValueOf := ConVal;
END;

BEGIN
Writeln(ValueOf('10001', 2));
END.