Sunteți pe pagina 1din 14

1.

Să se calculeze valoarea funcţiei definită pe mulţimea numerelor reale, pentru un x


 x , dacax  0
2

citit de la tastatură : f  x   
0, dacax  0

Program P1;
uses crt; x=5
var x,f:real; functia este: 2.00
begin
clrscr; x=-3
write('x='); functia este: 9.00
readln(x);
if x<=0 then
f:=sqr(x)
else
f:=0;
writeln('functia este:',f:5:2);
readln;
end.

2. Să se calculeze valoarea funcţiei, care citeşte două numere întregi x şi y şi afişează 0


dacă x=y, 1 dacă x<y şi 2 dacă x>y.

Program P2;
var x,y,f:integer; x=1
begin y=1
write('x='); functia este:0
readln(x);
write('y='); x=3
readln(y); y=9
if x=y then functia este:1
f:=0
else x=6
if x<y then y=-2
f:=1 functia este:2
else
f:=2;
writeln('functia este:',f);
readln;
end.
x=1
y=1
functia este:0

3. De calculat valoarea funcţiei:


3,5  7  2,5 x 2 , x  5

y   5 ,5  x  6
 x  6
cos , x  10
 x  5

Program P3; var x,y:real;


begin
write('x='); x=4
readln(x); functia este: 0.98
if x<5 then
y:=3.5+7*x-2.5*sqr(x);
if (x>=5) and (x<=6) then x=5.5
y:=sqrt(5) functia este: 2.24
else
y:=cos((x-6)/(x+5));
x=10
writeln('functia este:',y:5:2); functia este: 0.96
readln;
end.

3 x 2  12, x  10

 x2  4
4. De calculat valoarea funcţiei: y  
 x 1
,10  x  12

ln  x  11  7 x
 2
, x  12

Program P4;
uses crt;
var x,y:real;
begin x=7
clrscr; functia este:135.00
write('x=');
readln(x); x=11
if x<10 then functia este:12.50
y:=3*sqr(x)-12;
if (x>=10)and(x<12) then
y:=(sqr(x)+4)/(x-1); x=12
if x>=12 then functia este:-1008.00
y:=ln(x-11)-7*sqr(x);
writeln('functia este:',y:5:2);
readln;
end.

5. Să se calculeze valoarea funcţiei f definită pe mulţimea numerelor reale, pentru un x


 x, x  0

citit de la tastatură: f 

0,0
x

 x
 3, x


3
3

Program P5; f:=x;


uses crt; if (x>=0)and(x<3) then
var x,f:real; f:=0;
begin if x>3 then
clrscr; f:=x-3;
write('x='); writeln('functia este:',f:5:2);
readln(x); readln;
if x<0 then end.
functia este: 0.00

x=4
functia este: 1.00
x=-1
functia este:-1.00

x=1

 4  x  x3 , x  4

100
6. Să se calculeze valoarea funcţiei: y  
 x
 1, 4, 4  x  10

x 2  10 x  2 , x  10

Program P6;
uses crt; x=4
var x,y:real; functia este:64.00
begin
clrscr; x=5
write('x='); functia este:21.40
readln(x);
if x<=4 then
y:=sqrt(4-x)+x*x*x; x=11
if (x>4)and(x<=10) then functia este:233.00
y:=100/x+1.4;
if x>10 then
y:=sqr(x)+10*x+2;
writeln('functia este:',y:5:2);
readln;
end.

7. Se consideră două numere întregi. Să se scrie un program care afişează numărul în


ordinea inversă. De exemplu la intrare a=5, b=7, iar la ieşire să se afişeze a=7, b=5.

Program p7; writeln('a=',a,' b=',b);


uses crt; readln;
var a,b,aux:integer;{aux-variabila auxiliara end.
ajutatoare}
begin
write('a=');
readln(a);
write('b=');
readln(b); a=5
aux:=a; b=7
a:=b; a=7 b=5
b:=aux;
8. Să se scrie un program pentru rezolvarea ecuaţiei pătrate ax 2  bx  c  0

program p8; end;


uses crt; if D=0 then
var a,b,c,x,x1,x2,D,xi:real;{ax^2+bx+c=0} begin
begin xi:=-b/2*a;
clrscr; writeln('x1=x2=x=',xi:5:2);
write('a='); end;
readln(a); if D<0 then
write('b='); writeln('nu exista solutii reale!');
readln(b);
write('c='); readln;
readln(c); end.
D:=sqr(b)-4*a*c;
if a=0 then
begin
writeln('ecuatie de gr. I');
x:=-(b/c);
writeln('solutia este: ',x:5:2); a=0
end b=1
c=2
else ecuatie de gr. I
if D>0 then solutia este: -0.50
begin
x1:=(-b-sqrt(sqr(b)-4*a*c))/2*a; a=2
x2:=(-b+sqrt(sqr(b)-4*a*c))/2*a; b=3
writeln('solutiile ecuatiei sunt: c=1
x1=',x1:5:2,' x2=',x2:5:2); solutiile ecuatiei sunt: x1=-4.00 x2=-2.00
9. Se consideră două numere întregi diferite. Să se afişeze numerele în ordine crescătoare.

Program p9;
uses crt;
var a,b:integer;
begin
clrscr;
write('a='); a=9
readln(a); b=-3
write('b='); -3 9
readln(b);
if(a>b)then
writeln(b,' ',a)
else
writeln(a,' ',b);
readln;
end.

10. Se consideră trei numere întregi. Să se ridice la pătrat numerele pozitive, celelalte
rămânând neschimbate.

program p10;
uses crt;
var a,b,c:integer;
begin
clrscr;
write('Introduce-ti trei numere:');
readln(a,b,c);
if (a>0)and(b>0)and(c>0) then
writeln(sqr(a),' ',sqr(b),' ',sqr(c));
if (a>0)and(b>0)and(c<0) then
writeln(sqr(a),' ',sqr(b),' ',c);
if (a>0)and(b<0)and(c>0) then Introduce-ti trei numere:-5
writeln(sqr(a),' ',b,' ',sqr(c)); -9
if (a>0)and(b<0)and(c>0) then 6
writeln(sqr(a),' ',b,' ',sqr(c)); -5 -9 36
if (a<0)and(b<0)and(c<0) then
writeln(a,' ',b,' ',c);
if (a<0)and(b<0)and(c>0) then
writeln(a,' ',b,' ',sqr(c));
if (a<0)and(b>0)and(c>0) then
writeln(a,' ',sqr(b),' ',sqr(c));
if (a<0)and(b>0)and(c<0) then
writeln(a,' ',sqr(b),' ',c);
readln;
end.
11. Se consideră numerele reale x,y şi z. Să se calculeze: max x  y  z, xyz  .

program p11;
uses crt;
var x,y,z,s,p:real;
begin
clrscr;
write('x='); x=8
readln(x); y=1
write('y='); z=1
readln(y); max(x+y+z, xyz)=10.00
write('z='); numerele sunt egale!
readln(z);
s:=x+y+z; x=2
p:=x*y*z; y=3.5
if (s>p) then z=4
writeln ('max(x+y+z, xyz)=',s:5:2); max(x+y+z, xyz)=28.00
if (s<p) then
writeln('max(x+y+z, xyz)=',p:5:2)
else
writeln('numerele sunt egale!');
readln;
end.
12. Se consideră numerele reale x,y şi z. Să se calculeze: min  x 2  y 2 , y 2  z 2  .

program p12;
uses crt;
var x,y,z,s1,s2:real;
begin
clrscr;
write('Introduce-ti trei numere:');
readln(x,y,z); x=-6
s1:=sqr(x)+sqr(y); y=5
s2:=sqr(y)+sqr(z); z=4
if (s1<s2) then min(xx+yy, yy+zz)=41.00
writeln ('min(xx+yy, yy+zz)=',s1:5:2);
if (s1>s2) then
writeln('min(xx+yy, yy+zz)=',s2:5:2);
readln;
end.

13. Se dau două numere naturale a şi b. Să se scrie un program care va verifica dacă
numărul a este divizor comun al lui b.

program p13;
uses crt;
var a,b:integer;
begin
clrscr; a=6
write('a='); b=12
readln(a); a este divizorul lui b
write('b=');
readln(b); a=7
if b mod a=0 then b=15
writeln('a este divizorul lui b') a nu este divizorul lui b
else
writeln('a nu este divizorul lui b');
readln;
end.

14. Se consideră trei numere întregi. Să se scrie un program care aranjează aceste numere
în ordine crescătoare.
program p14; if (b>a)and(b>c) then
uses crt; o:=b;
var a,b,c,m,n,o:integer; if (c>a)and(c>b) then
begin o:=c;
clrscr; writeln(m,' ',n,' ',o);
write('a='); readln;
readln(a); end.
write('b=');
readln(b);
write('c=');
readln(c);
if (a<b)and(a<c) then
m:=a;
if (b<a)and(b<c) then
m:=b;
if (c<a)and(c<b) then a=5
m:=c; b=8
if ((a>b)and(a<c))or((a<b)and(a>c)) then c=1
n:=a; 158
if ((b<a)and(b>c))or((b>a)and(b<c)) then
n:=b;
if ((c<a)and(c>b))or((c>a)and(c<b)) then
n:=c;
if (a>b)and(a>c) then
o:=a;

15. Să se scrie un program care citeşte de la tastatură două numere întregi a şi b. Dacă
primul este mai mic decât al doilea atunci să se afişeze cifra 1, dacă sunt egale cifra 2,
iar dacă al doilea este mai mare ca primul, atunci să se afişeze cifra 10.

program p15;
uses crt;
var a,b:integer;
begin a=5
clrscr; b=8
write('a='); 1
readln(a);
write('b='); a=5
readln(b); b=2
if a<b then 10
writeln('1');
if a=b then a=3
writeln('2'); b=3
if a>b then 2
writeln('10');
readln;
end.
16. Se introduce o cifră de la tastatură. Să se scrie un program care va determina dacă cifra
este pară sau impară.

program p16;
uses crt;
var a:integer;
begin
clrscr; a=8
write('a='); cifra para
readln(a);
if a mod 2=0 then a=9
writeln('cifra para') cifra impara
else
writeln('cifra impara');
readln;
end.

17. Să se scrie un program ce va determina de ce tip este un triunghi (echilateral, isoscel,


dreptunghic) cu laturile a, b şi c citite de la tastatură.

program p17; writeln('triunghi isoscel')


uses crt; else
var a,b,c:real; writeln('triunghi scalen');
begin end
clrscr; else
write('a='); writeln('triunghi inexistent');
readln(a); readln;
write('b='); end.
readln(b);
write('c=');
readln(c);
if ((a+b>c) and (b+c>a) and (a+c>b)) then a=8
begin b=9
if ((a=b)and(b=c)and(c=a)) then c=11
writeln('triunghi echilateral'); triunghi scalen
if ((sqr(b)+sqr(a)=sqr(c))or(sqr(b)
+sqr(c)=sqr(a))or(sqr(a)+sqr(c)=sqr(b))) a=7
then b=7
writeln('triunghi dreptunghic'); c=3
if (a=b)or(a=c)or(b=c) then triunghi isoscel
a=8
b=8
c=8
triunghi echilateral
triunghi isoscel
18. Indicaţi ordinea efectuării operaţiilor de mai jos:

a) 10+6*2/2;
b) (10+6*2)/2;
c) 3-8+21 div 3;
d) (10+6)*2/2;
e) 10+6*(2/2);
f) (2+3) mod 7 – 2.

a) 6*2/2+10;
b) (6*2+10)/2;
c) 21 div 3 +3-8;
d) (10+6)*2/2;
e) (2/2)*6+10;
f) (2+3) mod 7 – 2.

19. Ce va afişa secvenţele de program:

a) (5<2) or (5>8); Fals


b) (‘a’>’f’) and (10>=8); Fals
c) (abs(-6)<7) or (10<9); True
d) (6<=6) or (4>=3) and 10; True

20. Transformaţi numerele dintr-un sistem de enumeraţie în celălalt:

a) 961,0310    2
b) 51410    16
a) 0,03 * 2 = 0,06
961,0310  111000001, 0000011110 1011100001 012 0,06 * 2 = 0,12
0,12 * 2 = 0,24
961 = 2 * 480 + 1 0,24 * 2 = 0,48
480 = 2 * 240 + 0 0,48 * 2 = 0,96
240 = 2 * 120 + 0 0,96 * 2 = 1,92
120 = 2 * 60 + 0 0,92 * 2 = 1,84
60 = 2 * 30 + 0 0,84 * 2 = 1,68
30 = 2 * 15 + 0 0,68 * 2 = 1,36
15 = 2 * 7 + 1 0,36 * 2 = 0,72
7=2* 3+1 0,72 * 2 = 1,44
3=2* 1+1 0,44 * 2 = 0,88
0,88 * 2 = 1,76
0,76 * 2 = 1,52
96110  111000001 2 0,52 * 2 = 1,04
0,04 * 2 = 0,08
0,0310  0,00000111 101011100001012 0,08 * 2 = 0,16
0,16 * 2 = 0,32
0,32 * 2 = 0,64
0,64 * 2 = 1,28
0,28 * 2 = 0,56
0,56 * 2 = 1,12

0,12 * 2 = 0,24
b) 51410  0216
514 = 16 * 32 + 2
32 = 16 * 2 + 0

21. În secvenţele de mai jos schimbaţi instrucţiunea if prin instrucţiunea case:

if a = 1 then case a of
begin 1 : begin
a:=10; a:=10;
writeln(a); writeln(a);
end; end;
if a = 2 then 2 : writeln(‘eronat’);
writeln(‘eronat’); 3 : writeln(‘tot’);
if a = 3 then
writeln(‘tot’);

22. În secvenţele de mai jos schimbaţi instrucţiunea case prin instrucţiunea if:

case anotimp of if (anotimp=>3)and(anotimp<=5) then


3..5 : writeln(‘primavara’); writel(‘primavara’);
6..8 : writeln(‘vara’); if(anotimp=>6)and(anotimp<=8) then
9..11 : writeln(‘toamna’); writeln(‘vara’);
if(anotimp=>9)and(anotimp<=11) then
writeln(‘toamna’);

23. Care din identificatori sunt corecţi:

var i,j : integer;


x,y : real;
a,b : char;
p,q : boolean;

a) p:=false; (A)
b) i:=3.375; (F)
c) b:=’ha’; (A)
d) x+3:=y; (A)
e) j:=round(x/2); (F)
f) a:=’+’; (A)
g) x:=i+j mod 7; (A)
h) q:=odd(j+i div 5); (A)
i) y:=275; (A)

S-ar putea să vă placă și