Esercizi in pascal

Materie:Appunti
Categoria:Informatica

Voto:

1.5 (2)
Download:224
Data:25.05.2000
Numero di pagine:3
Formato di file:.txt (File di testo)
Download   Anteprima
esercizi-pascal_5.zip (Dimensione: 9.97 Kb)
trucheck.it_esercizi-in-pascal.txt     374 Bytes
readme.txt     59 Bytes


Testo

Program cancella_dato_in_lista;
type punt=^elemento ;
elemento=record
dato:integer;
next:punt;
end;
procedure cancella (var pp:punt ;xx:integer);
var p :punt;
begin
while (pnil) do
begin
if [(p^.dato) mod 2] = 0
then begin
r:=p ;
p:=p^.next ;,
end;
r^.next:=p^.next ;
dispose:=(p); (* non l'ho corretto *)
end;
program conta_maggiori; (*2 mar 98*)
const n=10;
var a:array[1..n] of integer; (*per ogni elemento indicare*)
i,j,aux,conta :integer; (* il numero degli elemnti *)
begin (* maggiori *)
conta:=0;
for i:= 1 to n do
readln(a[i]);
for i:= (n-1) downto 1 do (*inizio bubble sort*)
for j:= 1 to i do
if (a[j] > a[j+1]) then
begin
aux:= a[j] ;
a[j]:=a[j+1];
a[j+1]:=aux;
end; (*fine bubble sort*)
for i:= 1 to n do
begin
conta:=0 ;
for j:= 1 to (n-i) do
begin
if (a[i] num
then si:=false;
prec:=num
end;
until num=0;
if not (si)
then write ('La sequenza non Љ crescente.')
else write('La sequenza Љ crescente.');readln
end.
Program studenti; (*14-5-98*)
const max=3;
type cifre = array[1..max] of integer;
lettere = array[1..10] of char;
studente = record
matricola : cifre;
cognome :lettere;
end;
vettore = array [1..max] of studente;
var a: vettore ;
procedure leggi_studenti (var c :vettore);
var i :integer;
begin
for i := 1 to max do
begin
WITH c[i] do
begin
writeln('Inserisci cognome studenti ');
readln (cognome[i]);
writeln('Inserisci matricola corrispondente ');
readln (matricola[i]);
end;
end;
end;
procedure selection (var b:vettore);
var i,j :integer;aux : vettore;
begin
WITH b[i] do
begin
for i:= 1 to (max-1) do
for j := i+1 to max do
if (matricola[i])>(matricola[j]) then
begin
aux[i]:=b[j];
b[j]:= b[i];
b[i]:=aux[i];
end;
end;
write('L''elenco ordinato Љ ...');
for i:= 1 to max do
WITH b[i] do
begin
for j:=1 to 10 do
write (cognome[i]);
writeln (matricola[i]);
end;
end;
begin (* main *)
leggi_studenti(a);
selection(a);
end. program gaspare ;
var b,c,d,Vc,Vo,M,M2:real; (*devo fare un programma per *)
var G,ag,raggioT,pigreco:real; (*formule di fisica*)
var alpha,beta,gamma :real;
var Velocita,tempo,spazio,h,peso,F,a:real;
var massagr,massakg :real;
var ENcin,ENpot,ENtot :real;
var bo:real;
BEGIN
pigreco:=3.14159265 ;
G:=6.67*(10*sqr(-11));
ag:=9.81; (*metri al sec.quadro*)
raggioT:=6370000 (*metri*);
writeln('che devi calcolare?',bo);
writeln('massa: ',massagr);
writeln('massa: ',massakg);
writeln ('tempo(in sec.): ',tempo);
writeln ('spazio(in metri): ',spazio);
writeln ('altezza: ',h);
velocita:=spazio/tempo ;
velocita:=a*tempo ;
a:=velocita*tempo ;
F:=massakg*a ; (*in newton kg X m/s X s *)
ENcin:=0.5*massakg*(velocita*sqr(2)) ;
ENpot:=massakg*h*ag ;
ENtot:=ENcin+ENpot ;
readln
end.

end. program frequenza;
const n=5;
var a:array[1..n] of integer;
b:array[1..n]of integer;
i,j,k,maxconta,conta : integer;
begin
maxconta:=0;
for i:=1 to n do
readln(a[i]);
for i:=1 to n do
begin
conta:=0 ;
for j:=i to n do
begin
if a[i]=a[j] then
begin
conta:=conta+1;
end;
b[j]:=conta;
end;
write ('la frequenza dell''elemento ',a[i],' Љ ',b[i]);
end;
(*if maxconta

Esempio