Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Compile and Execute Pascal Online

Program tarea1;
const MAXLARGO = 7;
var 
	b1,b2,b3,n: char;
	p1,p2,base, cont: integer;
	guard: LongInt;
	
begin
	base:= 0;
	guard:= 0;
	repeat
		(*Lectura de base*)
		guard:= 0;
		read(b1,b2); 
		p1:=ord(b1) - 48;
		if b2<>':' then 
			begin
			     p2:=ord(b2) - 48;
			     base:= p1*10 + p2;
			     read(b3);
			end
		else
			begin
				base:= p1;
				b3:= b2; 
			end;
        (*Lectura de numero*)
		if b3=':' then 
			begin
				cont := 0;
				repeat
					read(n);
					if (n<>'.') then
						begin
						    if(cont + 1 > MAXLARGO) then
						    begin
						        writeln('ERROR LOCO');
						        break;
						    end;
							(*Revision de tipo de entrada*)
							if ord(n) >= 65 then
								begin
									if ord(n) <= 70 then guard:= guard * base + (ord(n) - 55);
								end
							else guard:= guard * base + (ord(n) - 48);
							cont := cont + 1;						
						end;
				until (n='.') or (cont> MAXLARGO);
				if (cont> MAXLARGO) then writeln('ERROR')
				else writeln(guard);
				readln();
			end;						
	until (b1= '$') or (cont> MAXLARGO);
end. 

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.