Infine illustrerò anche link di siti che contengono altri programmi.
1: Calcolare l'area e il perimetro di un rettangolo
program RETTANGOLO;
uses crt;
var b,h,A,P : integer;
begin
clrscr;
write ('ASSEGNA LA BASE=');
readln(b);
write ('ASSEGNA L''ALTEZZA=');
readln(h);
A:=b*h;
P:=2*(b+h);
writeln ('L''AREA Š:' ,A);
write (' IL PERIMENTRO Š: ' ,P);
readln;
end.
2: Effettuare lo sconto inserendo i tassi e il riferimento in base al quale applicare lo sconto
program scontare;
Uses crt;
Var PREZZO,T1,T2,RIF,X,IMP,SCONTO,FINE:real;
Begin
Clrscr;
Write('DAMMI IL PREZZO=');
Readln (PREZZO);
Write('DAMMI IL T1=');
Readln (T1);
Write('DAMMI IL T2=');
Readln (T2);
Write('DAMMI IL RIF =');
Readln(RIF);
IF PREZZO > RIF THEN
Begin
SCONTO:=PREZZO * T1 / 100;
Write('Lo Sconto è: ',SCONTO:3:2);
Readln;
end
Else
Begin
SCONTO:= PREZZO * T2 / 100;
Write('Lo Sconto è= ',SCONTO:3:2);
readln;
end;
readln;
IMP:=PREZZO - SCONTO;
Write('Il Prezzo Finale è= ',IMP:3:2);
Readln;
End.
3: Calcolare il massimo di tre valori
program max;
VAR VAL1, VAL2, VAL3, MAX: integer;
begin
Writeln ('Primo valore');
Readln (VAL1);
Writeln ('Secondo valore');
Readln (VAL2);
writeln ('Terzo valore');
Readln (VAL3);
Begin
If VAL1 > VAL2 Then If VAL1 > VAL3 Then MAX:= VAL1
Else MAX:= VAL2
End;
Begin If NUM2 > NUM3 Then MAX:= NUM2
Else MAX:=VAL3;
End ;
Writeln ('Il valore maggiore è ', MAX);
READLN
END.
4: Pagamento delle ore di sosta in un parcheggio, attribuendo valori diversi tra la prima ora e tutte le successive
program parcheggio;
uses crt;
var s1,ss,ore,imp:real;
begin
clrscr;
write('Digitare le ore di sosta=');
readln(ore);
write('Assegnare l''importo per la prima ora di sosta=');
readln(s1);
write('Assegnare l''importo per le ore successive=');
readln(ss);
if(ore>1)then
begin
imp:=(((ore-1)*ss)+s1);
write('L''importo da pagare è: ',imp:3:2);
readln;
end
else
write('L''importo da pagare è: ',s1);
readln;
end.
5: Calcolo del rimborso di una determinata cifra per un percorso fatto in autobus
PROGRAM rimborso;
USES CRT;
VAR
PROV,MEZZ: STRING;
KILOM,COSTO: REAL;
BEGIN
CLRSCR;
WRITELN('SCRIVI IN MAIUSCOLO!');
WRITELN;
WRITE('INSERISCI PREZZO DELL''ABBONAMENTO: ');
READLN(COSTO);
WRITE('SIGLA DELLA PROVINCIA (FG): ');
READLN(PROV);
WRITE('QUANTI KM PERCORRI (=>20): ');
READLN(KILOM);
WRITE('MEZZO DI TRASPORTO (''AUTOBUS'' O ''TRENO''): ');
READLN(MEZZ);
WRITELN;
IF PROV='FG' THEN
BEGIN
IF KILOM>=20 THEN
BEGIN
IF MEZZ='AUTOBUS' THEN
BEGIN
WRITE('IL RIMBORSO E'' DI: ',COSTO*15/100:3:2);
READLN;
END
ELSE
BEGIN
IF MEZZ='TRENO' THEN
WRITE('IL RIMBORSO E'' DI: ',COSTO*10/100 :3:2);
READLN;
END;
END;
END;
END.
Ora passiamo a qualcosa di più complesso , introducendo anche discorsi riguardanti la grafica e l'interfaccia del programma che abbiamo creato.
6: Controllo ordine dei numeri
program controllo_ordine;
uses crt;
var i,l,vet,som,d:integer;
vettore:array[1..1000] of integer;
let:char;
begin
vet:=0;
som:=0;
d:=0;
repeat
textcolor(lightred); textbackground(blue);
clrscr;
write('Programma che controlla se un vettore Š ordinato in modo crescente o decresente!');
textcolor(11);
gotoxy(1,4);
writeln('Inserisci "c" per il controllo crescente');
writeln('Iserisci "d" per il controllo decrescente');
textcolor(lightgreen);
write('Scelta --> ');
readln(let);
if ((let<>'c')and(let<>'d')) then
clrscr;
until ((let='c')or(let='d'));
textcolor(13);
for i:=1 to 80 do write(char(205));
if let='c' then
begin
gotoxy(35,8);
textcolor(yellow);
writeln('CRESCENTE');
end
else
begin
textcolor(yellow);
gotoxy(34,8);
writeln('DECRESCENTE');
end;
textcolor(13);
for i:=1 to 80 do write(char(205));
repeat
gotoxy(1,11);
textcolor(11);
write('Inserisci il numero di elementi da inserire nel vettore = ');
readln(l);
until l>1;
if let='c' then
begin
for i:=1 to l do
begin
write('Inserisci ',i,'ø elemento del vettore = ');
readln(vettore[i]);
end;
textcolor(lightgreen);
if l=2 then
begin
if vettore[1]<vettore[2] then
begin
gotoxy(1,13+l);
writeln('Il vettore Š ordinato!!');
end
else
begin
gotoxy(1,13+l);
writeln('Il vettore non Š ordinato!!');
end;
end
else
begin
for i:=1 to l-1 do
begin
If vettore[i]<vettore[i+1] then
vet:=vet+1
else
som:=som+1;
end;
if ((vet<>0)and(som=0)) then
begin
gotoxy(1,13+l);
writeln('Il vettore Š ordinato!!');
end
else
begin
gotoxy(1,13+l);
writeln('Il vettore non Š ordinato!!');
end;
end;
end;
if let='d' then
begin
for i:=1 to l do
begin
write('Inserisci ',i,'ø elemento del vettore = ');
readln(vettore[i]);
end;
textcolor(lightgreen);
if l=2 then
begin
if vettore[1]>vettore[2] then
begin
gotoxy(1,13+l);
writeln('Il vettore Š ordinato!!');
end
else
begin
gotoxy(1,13+l);
writeln('Il vettore non Š ordinato!!');
end;
end
else
begin
for i:=1 to l-1 do
begin
If vettore[i]>vettore[i+1] then
vet:=vet+1
else
som:=som+1;
end;
if ((vet<>0)and(som=0)) then
begin
gotoxy(1,13+l);
writeln('Il vettore Š ordinato!!');
end
else
begin
gotoxy(1,13+l);
writeln('Il vettore non Š ordinato!!');
end;
end;
end;
readln();
end.
N.B.= Il simbolo Š che trovate ogni tanto è uguale a "è" che sul blocco note viene modificato automaticamente!
Potete trovare molti altri programmi cliccando QUI
Per ulteriori informazioni, spiegazioni e domande, non esitate a contattarmi!
0 commenti:
Posta un commento