PROBLEME q6i8ih
De Apostol Vlad & Al-Zaim .....bla bla
1.
Program afisare_alfabet;
AAcest program afiseaza toate literela mari in ordine invers alfabeticaS
Uses crt;
Var a:char;
Begin
Clrscr;
For a:=’Z’ downto ‘A’ do write(a,’,’);
AAm folosit instructiunea “For…to,For…downto”.”a”
ia valori de la Z pana la AS
Readln;
End.
2.
Program anotimpuri;
AAcest program afiseaza un anotimp corepunzator tastei apasateS
Uses crt;
Var nr:char;
Begin
Clrscr;
Write(‘Dati numarul anotimpului: ‘);
Nr:=readkey;
AReadkey este o functie a bibliotecii CRT care returneaza un caracter - corepunzator
tastei apasateS
Case nr of
‘1’: write(‘primavara’);
‘2’: write(‘vara’);
‘3’: write(‘toamna’);
‘4’: write(‘iarna’);
AAm folosit istructiunea “Case” cu ajutorul careia am luat fiecare
caz in parteS end readln; end.
3.
Program perimetru_arie;
AAcest program calculeaza aria shi perimetrul unui triunghiS
Uses crt;
Var perimetrul,p,a,b,c,arie:real;
Begin
Clrscr;
Write(‘introduceti prima latura: ‘);
Readln(a);
Write(‘Introduceti cea de-a doua latura: ‘);
Readln(b);
Write(‘Introduceti cea de-a treia latura: ‘);
Readln(c); p:=(a+b+c)/2;
Arie:=sqrt(p*(p-a)*(p-b)*(p-c));
Writeln(‘Aria este: ‘,arie:7:2);
A“ arie:7:2 inseamna ca rezultatul poate avea 7 cifre inainte de virgula
si 2 cifre dupa virgulaS
Perimetrul:=a+b+c;
Writeln(‘Perimetrul este: ‘,perimetrul:7:2);
Readln;
End.
4.
Program triunghi_dreptunghic;
AAcest program calculeaza perimerul, aria si ipotenuza unui triunghi dreptunghicS
Uses crt;
Var a,b,c,p,arie:real;
Begin
Clrscr;
Write(‘Dati valoarea lui a: ‘);
Readln(a);
Write(‘Dati valoarea lui b: ‘);
Readln(b); c:=sqrt(sqr(a)+sqr(b)); p:=a+b+c; arie:=(a*b)/2;
writeln(‘Ipotenuza este: ‘,c:7:2);
writeln(‘Perimetrul este: ‘,p:7:2);
writeln(‘Aria este: ‘,arie:7:2); readln; end.
5.
Program nume;
AAcest program afiseaza doua nume in ordine alfabeticaS
Uses crt;
Var n1,n2:string;
A“n1,n2:string” inseamna ca n1 si n2 sunt siruri de caractere cuprinse
intre apostrofuriS
Begin
Clrscr;
Write(‘Primul nume este: ‘);
Readln(n1);
Write(‘Al doilea nume este: ‘);
Readln(n2);
If n1>n2 then writeln(n2,’ ‘,n1)
Else writeln(n1,’ ‘,n2);
ADaca n1>n2 atunci va afisa n2,n1 sau altfel n1,n2S
Readln;
End.
6.
Program optiune;
AAcest program calculeaza ,dupa dorinta utilizatorului, media aritmetica sau
media geometricaS
Uses crt;
Var a,b,ma,mg:real; op:char;
AChar este o instructiune string dar are un singur caracter cuprins intre apostrofuriS
Begin
Clrscr;
Write(‘Dati valoarea lui a: ‘);
Readln(a);
Write(‘Dati valoarea lui b: ‘);
Readln(b);
Write(‘Ce doriti sa calculam? (1)-ma, (2)-mg’);
Readln(op);
If op’1’ then
Begin
Ma:=(a+b)/2;
Writeln(‘Media aritmetica este: ‘,ma:5:2);
End
ADaca utilizatirul a ales optiunea 1 atunci se va calcula media aritmeticaS
Else
If op=’2’ then
Begin
Mg:=sqrt(a*b);
Writeln(‘Media geometrica este: ‘,mg:5:2);
End
Else
If op>’2’ then writeln(‘Nu ati ales una dintre optiuni’);
Readln;
End.
7.
Program piramida;
Uses crt;
Var u,I,j:integer;
Begin
Clrscr;
Write(‘Dati valoarea lui n: ‘);
Readln(n);
For I:=1 to n do
Beginfor j:=1to I do write(j:2);
Writeln;
End;
Readln;
End.
8.
Program unghiuri;
Uses crt;
Var g,g1,g2,m,m1,m2,s,s1,s2:integer;
Begin
Clrscr;
Write(‘Dati marimea primului unghi: ‘);
Readln(g1,m1,s1);
Write(‘Dati valoarea celui de-al doilea unghi: ‘);
Readln(g2,m2,s2); g:=g1+g2; m:=m1+m2; s:=s1+s2;
If s>60 then begin m:=m+1; s:=s-60 end;
If m>60 then begin g:=g+1; m:=m-60; end;
writeln(‘Suma este: ‘,g,’ grade ‘,m,’ minute ‘,s,’
secunde ‘); readln; end.
9.
Program patrat;
Uses crt;
Var n:integer;
Begin
Clrscr;
Write(Dati valoarea lui n: );
Readln(n);
For n:=1 to 9 do
If n*(n-1) mod 10=0 then writeln(n);
For n:=11 to 99 do
If n*(n-1) mod 100=0 then writeln(n);
For n:=101 to 999 do
If n*(n-1) mod 1000=0 then writeln(n);
Readln;
End.
10.
Program numar_roman;
Uses crt.
Var x:integer;
Begin
Write(‘Dati numarul arab’);
Readln(x);
Write(x,’=’);
While x>=1000 do begin write(‘M’); x:=x-1000;
End;
If x>=900 then begin write(‘CM’); x:=x-900; end; else if x>=500 then begin write(‘D’); x:=x-500; end; else if x>=400 then begin write(‘CD’); x:=x-400; end;
while x>=100 then begin write(‘C’); x:=x-100; end; if x>=90 then begin write(‘XC’); x:=x-90; end; else if x>=50 then begin write(‘L’); x:=x-50; end; else if x>=40 then begin write(‘XL’); x:=x-40; end;
while x>=10 then begin write (‘X’) x:=x-10; end;
If x>=9 then begin write (‘IX’); x:=x-9; end; else if x>=5then begin write (‘V’); x:=x-5; end; else if x=4 then begin write (‘IV’) x:=x-4; end;
while x>=1do begin write(‘I’); x:=x-1; end; readln; end.