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 HelloWorld(output);
begin
  writeln('Hello, world!');
end.

Compile and Execute Pascal Online

{Class:4B
Name:Kuok Chun Cho}
Program MyFirst;
begin
   writeln('welcome to pascal programming!');
   writeln('This is my first program!');
   writeln('Hey guys!')
end.

Compile and Execute Pascal Online

{Class:4B
 Name:Lee Chun Hei}
program MyFirst;
begin
   writeln('welcome to Pascal Programming!');
   writeln('This is my first program!')
end.

Compile and Execute Pascal Online

{Class: 4B
Name: Kanlokyee }
Program MyFirst;
begin
  writeln('Welcome to Pascal Programming');
  writeln('This is my first program!')  
end.

test

Program roots(output);
var 
a,b,c,d,e,root,x:real;
begin
 write('a=');
 read(a);
 write('b=');
 read(b);
 write('c=');
 read(c);
 write('d=');
 read(d);
 write('e=');
 read(e);
 x:=(a+b+c+d+e);
 root:=(x/5);
 writeln('root=',root);
end.

(a+b+c+d)/5

program roots(output);
var
a,b,c,d,e,root,x1,x2:real;
begin
write('a=');
read(a);
write('b=');
read(b);
write('c=');
read(c);
write('d=');
read(d);
write('e=');
read(e);
root:=(a+b+c+d+e);
x1:=root;
x2:=(root)/5;
writeln;
writeln('x1=',x1:6:2,' x2=',x2:6:2);
end.

Compile and Execute Pascal Online

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.

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. 

Vi du 1 - Nhom 3 - Lop 11/17

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.

Compile and Execute Pascal Online

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.

Advertisements
Loading...

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