sintassi con turbo pascal 1.1 su mac
program matrix1;
var a,b:integer; mat:array[1..2,1..3] of integer; begin for a:=1 to 2 do for b:=1 to 3 do begin write('dato numerico n.','riga:',A,' colonna:',B,' = '); readln(mat[a,b]); end; writeln; for a:=1 to 2 do begin for b:=1 to 3 do begin write(mat[a,b],' .. '); writeln; end; end; writeln('premi return'); readln; end.
program matrix2;
var a,b:integer; mat:array[1..2,1..3] of STRING[4]; begin for a:=1 to 2 do for b:=1 to 3 do begin write('dato 4 lettere n.','riga:',A,' colonna:',B,' = '); readln(mat[a,b]); end; writeln; for a:=1 to 2 do begin for b:=1 to 3 do begin write(mat[a,b],' .. '); writeln; end; end; writeln('premi return'); readln; end.
program matrix3;
var b:integer; A:CHAR; mat:array['a'..'b',1..3] of STRING[4]; begin for a:='a' to 'b' do for b:=1 to 3 do begin write('dato 4 lettere n.','riga:',A,' colonna:',B,' = '); readln(mat[a,b]); end; writeln; for a:='a' to 'b' do begin for b:=1 to 3 do begin write(mat[a,b],' .. '); writeln; end; end; writeln('premi return'); readln; end.
program medie;
const n=5; n1=6; type serie=1..10; var nome:array[serie] of integer; g1:array[serie] of real; g2:array[serie] of real; g3:array[serie] of real; g4:array[serie] of real; g5:array[serie] of real; g6:array[serie] of real; media:array[serie] of real; somma,mediam:real; k,q:integer;
begin writeln('scrivi:numero matricola e voti per allievo:',n); writeln(N1,':numeri separati con SPACE:return alla fine'); writeln('scrivi tutti 0 per finire'); writeln('-----------------------------------------'); k:=0; repeat k:=k+1; readln(nome[k],g1[k],g2[k],g3[k],g4[k],g5[k]); until nome[k]=0;
writeln('numero matricola ':20,' media ':20); for q:=1 to k-1 do begin media[Q]:=(g1[Q]+g2[Q]+g3[Q]+g4[Q]+g5[Q])/n; writeln(nome[q]:20,media[q]:20:1); end; mediam:=0.0; for q:=1 to k-1 do begin if media[q] > mediam then mediam:=media[q]; end; writeln('media massima=',mediam:20:1); writeln; writeln('premi return'); readln; end.
program sezione;
type giorni=(lunedi,martedi,mercoledi,giovedi,venerdi,sabato,domenica); numeri=1..20; feriali=lunedi..sabato; var giorno:giorni; lavoro:feriali; numero:numeri;
begin for lavoro:=lunedi to sabato do write(ord(lavoro),'......'); writeln; for giorno:=lunedi to domenica do write(ord(giorno),'++++++'); writeln; writeln('scrive 20 numeri consecutivi'); for numero:=1 to 20 do write(ord(numero),'..'); writeln; writeln('premi return'); readln; end.
PROGRAM VETTORI;
VAR A:INTEGER; VET:ARRAY[1..5] OF INTEGER; BEGIN FOR A:=1 TO 5 DO BEGIN WRITE('dato n.',A,' ='); READLN(vet[a]); end; writeln; for a:=1 to 5 do writeln(vet[a]); writeln; for a:=5 downto 1 do writeln(vet[a]); writeln('premi return'); readln; end.
PROGRAM USASANE;
USES SANE; VAR X:EXTENDED; A:LONGINT;
BEGIN X:=125.23456; A:=NUM2LONGINT(X); writeln(A); writeln('premi return'); readln; end.