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.
{Class:4B
Name:Kuok Chun Cho}
Program MyFirst;
begin
writeln('welcome to pascal programming!');
writeln('This is my first program!');
writeln('Hey guys!')
end.
Program HelloWorld(output);
{$MODE Delphi}
uses
SysUtils;
////////////////////////////////////////////////////////////////////////////////
function IntToLetters(Number: Cardinal): string;
var
Modulo: Cardinal;
begin
Result := '';
while (Number > 0) do begin
Modulo := (Number - 1) mod 26;
Result := Char(65 + Modulo) + Result;
Number := (Number - Modulo) div 26;
end;
end {IntToLetters};
////////////////////////////////////////////////////////////////////////////////
function LettersToInt(Letters: string): Cardinal;
var
i: Integer;
begin
Letters := UpperCase(Letters);
Result := 0;
for i := 1 to Length(Letters) do begin
Result := Result * 26;
Inc(Result, Ord(Letters[i]) - 64);
end;
end {LettersToInt};
procedure TestValue(const i: Integer);
var
IL: string;
ILI: Integer;
begin
Write(i, #9);
IL := IntToLetters(i);
Write(IL, #9);
ILI := LettersToInt(IntToLetters(i));
WriteLn(ILI);
Assert(i = ILI);
end;
var
i: Integer;
begin
for i := 0 to 1024 do begin
TestValue(i);
end;
TestValue(16383);
TestValue(16384);
TestValue(16385);
TestValue(65535);
TestValue(65536);
TestValue(65537);
end.
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.
Program Vd1;
uses crt;
var M,N: real;
begin
writeln('Nhap gia tri M,N: ');
readln(M,N);
while M<>N do
if M=N then M:=M-N else N:=N-M;
writeln('UCLN= ',M);
readln;
end.
Program Vd1;
uses crt;
var M,N: real;
begin
writeln('Nhap gia tri M,N: ');
readln(M,N);
while M<>N do
if M=N then M:=M-N else N:=N-M;
writeln('UCLN= ',M);
readln;
end.