Documente online.
Zona de administrare documente. Fisierele tale
Am uitat parola x Creaza cont nou
 HomeExploreaza
upload
Upload




Rezolvari variante bacalaureat

Informatica


Varianta 1:

d.

2. a. b.



c. citeste n

z

p

daca n>0 atunci

│ repeta

│ │ c n%10

│ │ n [n/10]

│ │ daca c%3=0 atunci

│ │ │ z z+p*(9-c)

│ │ │ p p*10

│ pāna cānd n<=0

scrie z

d. var n,z,p,c:longint;

begin

write('n= '); readln(n);

z:=0;

p:=1;

while n>0 do

begin

c:=n mod 10;

n:=n div 10;

if c mod 3 = 0

then begin

z:=z+p*(9-c);

p:=p*10;

end;

end;

write(' z= ',z);

end.

Varianta 2:

a.

2. a. b.

c. citeste x

daca x>0 atunci

│ repeta

│ │citeste y

│ │daca x>y atunci

│ │ │ scrie x%10

│ │ │ altfel

│ │ │ scrie y%10

│ │ x y

│ pāna cānd x<=0

d. var x,y:integer;

begin

write(' x= '); read(x);

while x>0 do

begin

write(' y= '); read(y);

if x>y

then write(x mod 10,' ')

else write(y mod 10,' ');

x:=y;

end;

end.

Varianta 3:

b

2. a. b.

c. citeste z,x

daca x>0 atunci

│ repeta

│ │ citeste y

│ │ daca z<y-x atunci

│ │ │ scrie x%10

│ │ │ altfel

│ │ │ scrie y%10

│ │ x y;

│ pana cānd x<=0

d. var x,y,z:integer;

begin

write(' z= '); read(z);

write(' x= '); read(x);

while x>0 do

begin

write(' y= '); read(y);

if z<y-x

then write(x mod 10)

else write(y mod 10);

x:=y;

end;

Varianta 4:

d

2. a.

b.

c. citeste a,b

daca a<b atunci

│ s a; a b; b s

x a

cat timp x>=b executa

│ daca x%2=0 atunci

│ │ scrie x,' '

│ x x-1

d. var a,b,x,s:integer;

begin

write(' a= '); read(a);

write(' b= '); read(b); 353v2115d

if a<b then begin

s:=a; a:=b; b:=s;

end;

for x:=a downto b do

if x mod 2 = 0

then write(x,' ');

end.

Varianta 5:

c

2. a. b.

c. invers(x)

daca x<>0 atunci

│ y y*10+x%10

│ invers( [x/100] )

citeste x,z

y

invers(x)

cat timp y*z>0 si y%10=z%10 executa

│ y [y/10]

│ z [z/10]

daca y+z=0 atunci

│ scrie 1

│ altfel

│ scrie 0

d. var x,y,z:longint;

begin

write(' x= '); read(x);

write(' z= '); read(z);

y:=0;

repeat

y:=y*10+x mod 10;

x:=x div 100;

until x=0;

while (y*z>0) and (y mod 10 = z mod 10) do

begin

y:=y div 10;

z:=z div 10;

end;

if y+z=0

then write(1)

else write(0);

end.

Varianta 6:

a

2. a. b. 39 (orice nr. care nu are toate cifrele in ordine descresc)

c. citeste n

s

daca n>0 atunci

│ repeta

│ │ daca n%10>s atunci

│ │ │ s n%10

│ │ │ altfel

│ │ │ s

│ │ n [n/10]

│ pāna cānd n<=0

scrie s

d. var n,s:longint;

begin

write(' n= '); read(n);

s:=-1;

while n>0 do

begin

if n mod 10 > s

then s:=n mod 10

else s:=11;

n:=n div 10

end;

write(' S= ',s);

end.

Varianta 7:

d

2. a. b. 69645 si 55946

c. citeste n

nr

a

repeta

│ m n

│ cat timp m≠0 si m%10≠a executa

│ │ m [m/10]

│ daca m≠0 atunci

│ │ nr nr*10+m%10

│ a a-1

pāna cānd a<=0

scrie nr

d. var n, nr, m, a:longint;

begin

write(' n= '); read(n);

nr:=0;

for a:=9 downto 0 do

begin

m:=n;

while (m<>0) and (m mod 10 <>a) do

m:=m div 10;

if m<>0

then nr:=nr*10+m mod 10

end;

write(' nr= ',nr);

end.

Varianta 8:

a

2. a. b. 7935 si orice k (orice numar cu toate cifrele impare)

c. citeste n, k

nr

p

daca n≠0 si k≠0

│ atunci repeta

│ │ daca n%2=0 atunci

│ │ │ nr nr+n%10*p

│ │ │ p p*10

│ │ │ altfel

│ │ │ k k-1

│ │ n [n/10]

│ pāna cānd n=0 sau k=0

scrie nr

d. var n, k, nr, p:longint;

begin

write(' n= '); read(n);

write(' k= '); read(k);

nr:=0;

p:=1;

while (n<>0) and (k<>0) do

begin

if n mod 2 = 0

then begin

nr:=nr+n mod 10 * p;

p:=p*10;

end

else k:=k-1;

n:= n div 10;

end;

write(' nr= ',nr);

end.

Varianta 9:

b

2. a. b. 2317 (orice numar care nu are cifrele in ordine cresc.)

c. citeste n

s

daca n>0 atunci

│ repeta

│ │ daca n%10<s

│ │ │ atunci s n%10

│ │ │ altfel s

│ │ n [n/10]

│ pāna cānd n<=0

scrie s

d. var n, s :longint;

begin

write(' n= '); read(n);

s:=10;

while n>0 do

begin

if n mod 10 < s

then s:= n mod 10

else s:= -1;

n:=n div 10;

end;

write(' s= ',s);

end.

Varianta 10:

a

2. a. b.

c. citeste n, k

nr

p

daca n≠0 si k≠0

│ atunci repeta

│ │ daca n%2=0 atunci

│ │ │ nr nr+n/10%10*p

│ │ │ p p*10

│ │ │ altfel

│ │ │ k k-1

│ │ n [n/10]

│ pāna cānd n=0 sau k=0

scrie nr

d. var n, k, nr, p:longint;

begin

write(' n= '); read(n);

write(' k= '); read(k);

nr:=0;

p:=1;

while (n<>0) and (k<>0) do

begin

if n mod 2 <> 0

then begin

nr:=nr+n div 10 mod 10 * p;

p:=p*10;

end

else k:=k-1;

n:= n div 10;

end;

write(' nr= ',nr);

end.

Varianta 11:

c

2. a. b. 54628 (orice nr. cu ultimele 4 cif pare)

c. var n, k, p, c:longint;

begin

write(' n= '); read(n);

write(' k= '); read(k);

p:=1;

while (n>0) and (k>0) do

begin

c:=n mod 10;

if c mod 2=1

then p:=p*c;

n:=n div 10;

k:=k-1;

end;

write(' p= ',p);

end.

d. citeste n,k

p

pentru i k,1,-1 executa

│ daca n>0

│ │ atunci c n%10

│ │ daca c%2=0

│ │ │ atunci p p*c

│ │ n [n/10]

scrie p

Varianta 12

d

2. a. b.

c. var x,y:longint;

begin

write(' x= '); read(x);

y:=0;

while x<>0 do

begin

while x>9 do

x:= x div 10;

y:=y*10+x;

write(' x= '); read(x);

end;

write(' y= ',y);

end.

d. citeste x

y

daca x≠0 atunci

│ repeta

│ │ daca x>9 atunci

│ │ │ repeta

│ │ │ │ x [x/10]

│ │ │ pāna cānd x<=9

│ │ y y*10+x

│ │ citeste x

│ pāna cānd x=0

scrie y

Varianta 13:

b

2. a. b.

c. var a,b,i,k,c,n:integer;

begin

write(' a= '); read(a);

write(' b= '); read(b); 353v2115d

k:=0;

for i:=a to b do

begin

n:=i; c:=0;

while n>0 do

begin

if n mod 2 =1

then c:=c+1;

n:=n div 10

end;

if c>0

then k:=k+1;

end;

write(' k= ',k);

end.

d. citeste a,b

k

i a

cāt timp i<=b executa

│ n i; c

│ cāt timp n>0 executa

│ │ daca n%2=1 atunci

│ │ │ c c+1

│ │ n [n/10]

│ daca c>0

│ │ atunci k k+1

│ i i+1

scrie k

Varianta 14:

1. a

2. a. b. 371 35 211 0 (oricare 3 nr. cu cifra maxima subliniata)

c. var x, n, y, c:integer;

begin

write(' x= '); read(x);

n:=0;

while x<>0 do

begin

y:=x; c:=0;

while y>0 do

begin

if y mod 10 >c

then c:=y mod 10;

y:= y div 10;

end;

n:=n*10+c;

write(' x= '); read(x);

end;

write(' n= ',n);

end.

d. citeste x

n

daca x≠0 atunci

│ repeta

│ │ y x; c

│ │ daca y>0 atunci

│ │ │ repeta

│ │ │ │ daca y%10>c atunci

│ │ │ │ │ c y%10

│ │ │ │ y [y/10]

│ │ │ pāna cānd y<=0

│ │ n n*10+c

│ │ citeste x

│ pāna cānd x=0

scrie n

Varianta 15:

d

2. a. c. n = 4 d. a a-(i-1)*(i-1)

b. var a, n, i:integer;

begin

write(' a= '); read(a);

write(' n= '); read(n);

for i:=1 to n do

if i mod 2=0

then a:=a-i*i

else a:=a+i*i;

write(' a= ',a);

end.

Varianta 16:

a

2. a. ***#*** b.

c. var n, i, j,cont:integer;

begin

write(' n= '); read(n);

for i:=1 to n-1 do

begin

if i mod 2=0

then write('#');

for j:=i+1 to n do

write('*');

end;

end.

d. citeste n

i

cāt timp i<=n-1 executa

│ daca i%2=0

│ │ atunci scrie '#'

│ j i+1

│ cāt timp j<=n executa

│ │ scrie '*'

│ │ j j+1

│ i i+1

Varianta 17:

a

2. a. ABABABAB b. 6 perechi

c. var x, y:integer;

begin

write(' x= '); read(x);

write(' y= '); read(y);

if x<y

then begin

x:=x-y;

y:=x+y;

x:=y-x;

end;

while x>=y do

begin

write('A');

x:=x-y;

write('B');

end;

end.

d. citeste x,y

daca x<y atunci

│ x x-y

│ y x+y

│ x y-x

daca x≥y atunci

│ repeta

│ │ scrie 'A'

│ │ x x-y

│ │ scrie 'B'

│ pāna cānd x<y

Varianta 18:

c

2. a. **** b. 0 si 1

c. var x,y, aux:integer;

begin

write(' x= '); read(x);

write(' y= '); read(y);

if x>y

then begin

aux:=y;

y:=x;

x:=aux;

end;

if x mod 2=0

then x:=x+1;

while x<=y do

begin

x:=x+2;

write('*');

end;

end.

d. citeste x,y

daca x>y atunci

│ y x

daca x%2=0 atunci

│ x x+1

daca x≤y atunci

│ repeta

│ │ x x+2

│ │ scrie '*'

│ pāna cānd x>y

Varianta 19:

b

2. a. b. 312 si 335 (in intervalul format de cifrele

subliniate sa existe numai 2 numere multiplu de 11)

c. var a,b,i:integer;

begin

write(' a= '); read(a);

write(' b= '); read(b); 353v2115d

a:=a div 10 mod 10*10+a mod 10;

b:=b div 10 mod 10*10+b mod 10;

for i:=a to b do

if i div 10 = i mod 10

then write(i mod 10);

end.

d. citeste a,b

a [a/10]%10*10+a%10

b [b/10]%10*10+b%10

i a

cāt timp i<=b executa

│ daca[i/10]=i%10

│ │ atunci scrie i%10

│ i i+1

Varianta 20:

c

2. a. b.

c. var n,a,m,b:longint;

begin

write(' n= '); read(n);

a:=n mod 10;

m:=a;

while n>9 do

begin

n:=n div 10;

b:=n mod 10;

if a>b

then begin

m:=m*10+b;

a:=b;

end;

end;

write(' m= ',m);

end.

d. citeste n

a n%10

m a

daca n>9 atunci

│ repeta

│ │ n [n/10]

│ │ b n%10

│ │ daca a>b atunci

│ │ │ m m*10+b

│ │ │ a b

│ pāna cānd n<=9

scrie m

Varianta 21:

c

2. a.

b. citeste a,b,n

daca b=0

│ atunci scrie 'GRESIT'

│ altfel

│ scrie [a/b]

│ daca n>0 si a%b≠0 atunci

│ │ scrie ','

│ │ a a%b; i

│ │ scrie [(a*10)/10]

│ │ a (a*10)%b

│ │ i i+1

│ │ cāt timp i≠n si a≠0 executa

│ │ │ scrie [(a*10)/10]

│ │ │ a (a*10)%b

│ │ │ i i+1

c. var a, n, b, i:integer;

begin

write(' a= '); read(a);

write(' b= '); read(b); 353v2115d

write(' n= '); read(n);

if b=0

then write(' GRESIT')

else begin

write( a div b);

if (n>0) and (a mod b <>0)

then begin

write(',');

a:=a mod b; i:=0;

repeat

write((a*10) div b);

a:=(a*10) mod b;

i:=i+1;

until (i=n) or (a=0)

end;

end;

end.

d. a=29, b=4 si n=4 (oricare 2 nr. care īmpartite sa aiba numai n-2 zecimale)

Varianta 22:

b

2. a. b.

c. var n,d,i:integer;

begin

write(' n= '); read(n);

if n<0

then n:=-n;

d:=1;

for i:=2 to n div 2 do

if n mod i =0

then d:=i;

write(' d= ',d);

end.

d. 25 (orice numar cu un singur divizor in intervalul [2,n/2])

Varianta 23:

a

2. a. b. 4, 9 si 14

c. var a,b,p:integer;

begin

write(' a= '); read(a);

write(' b= '); read(b); 353v2115d

p:=0;

while a<>b do

begin

p:=p+1;

if a<b

then a:=a+2

else b:=b+3;

end;

write(' p= ',p);

end.

d. citeste a,b

p

daca a≠b atunci

│ repeta

│ │ p p+1

│ │ daca a<b

│ │ │ atunci a a+2

│ │ │ altfel b b+3

│ pāna cānd a=b

scrie p

Varianta 24:

d

2. a. b. 12 .si 60

c. var a,b,p,q:integer;

begin

write(' a= '); read(a);

write(' b= '); read(b); 353v2115d

p:=a; q:=b;

if (p=0) or (q=0)

then begin

p:=p*q;

q:=p*q;

end;

while p<>q do

if p<q

then p:=p+a

else q:=q+b;

write(' p= ',p);

end.

d. citeste a,b

p a; q b

daca p=0 sau q=0 atunci

│ p p*q; q p*q

daca p≠q atunci

│ repeta

│ │ daca p<q

│ │ │ atunci p p+a

│ │ │ altfel q q+b

│ pāna cānd p=q

Varianta 25:

c

2. a. 12 si 18 d. [(b-a+a%c)/c]

b. citeste a,b,c

daca a>b atunci

│ t a; a b; b t

pentru i a,b executa

│ daca c|i atunci

│ │ scrie a

c. var a,b,c,t:integer;

begin

write(' a= '); read(a);

write(' b= '); read(b); 353v2115d

write(' c= '); read(c);

if a>b

then begin

t:=a; a:=b; b:=t;

end;

while a<=b do

begin

if a mod c =0

then write(a,' ');

a:=a+1;

end;

end.

Varianta 26:

c

2. a.

b. var c,n,i:integer;

begin

write(' n= '); read(n);

c:=0;

for i:=1 to n do

begin

c:=(c+1) mod 10;

write(c,' ');

end;

end.

c. citste n

c

i

cāt timp i<=n executa

│ c (c+1)%10

│ scrie c

│ i i+1

d. 10 valori (21, 22, 23, 24, 25, 26, 27, 28, 29, 30)

Varianta 27:

a

2. a.

b. var a,b,c,p,d:integer;

begin

write(' a= '); read(a);

write(' b= '); read(b); 353v2115d

c:=0;

d:=0;

p:=1;

while a+b+c>0 do

begin

c:=a mod 10+b mod 10 + c;

d:=d+(c mod 10) *p;

p:=p*10;

a:=a div 10;

b:=b div 10;

c:=c div 10;

end;

write(' d= ',d);

end.

c. citeste a,b

c

d

p

daca a+b+c>0 atunci

│ repeta

│ │ c a%10+b%10+c

│ │ d d+(c%10)*p

│ │ p p*10

│ │ a [a/10]

│ │ b [b/10]

│ │ c [c/10]

│ pāna cānd a+b+c<=0

scrie d

d. citeste a,b

d a+b

scrie d

Varianta 28:

b

2. a.

b. var x,y:real;

begin

write(' x= '); read(x);

y:=trunc(x);

x:=x-y;

while x<>trunc(x) do

x:=x*10;

if x=y

then write(1)

else write(2);

end.

c. citeste x

y [x]

x x-y

daca x≠[x] atunci

│ repeta

│ │ x x*10

│ pāna cānd x=[x];

daca x=y atunci

│ scrie 1

│ altfel

│ scrie 2

d. 12.12 (orice numar in care partea īntrega este egala cu partea fractionala)

Varianta 29:

a

2. a.

b. var n,m:integer;

begin

write(' n= '); read(n);

write(' m= '); read(m);

while n<=m do

begin

n:=n+1;

m:=m-1;

end;

while m<n do

begin

m:=m+1;

n:=n-1;

end;

write(' n= ',n);

end.

c. 9 si 11 (oricare 2 numere egal departate de 10)

d. citeste n,m

scrie [(n+m)/2]

Varianta 30:

d

2. a.

b. var n,m,p,c:integer;

begin

write(' n= '); read(n);

m:=0;

p:=1;

while n>0 do

begin

c:=n mod 10;

if c>0

then c:=c-1;

m:=m+c*p;

p:=p*10;

n:=n div 10

end;

write(' m= ',m);

end.

c. citeste n

m

p

daca n>0 atunci

│ repeta

│ │ c n%10

│ │ daca c>0 atunci

│ │ │ c c-1

│ │ m m+c*p;

│ │ p p*10

│ │ n [n/10]

│ pāna cānd n≤0

scrie m

d. 3119 si 3009

Varianta 31:

b

2. a. b=1 k=6 b. 2 valori (3 si 5)

c. var a,k,b:integer;

begin

write(' a= '); read(a);

k:=0;

b:=(a+1)*(a+2) div 2;

while b>=a do

begin

b:=b-a;

k:=k+1;

end;

write(' b= ',b,' k= ',k);

end.

d. citeste a

b [(a+1)*(a+2)/2]

k [b/a]

b b%a

scrie b,k

Varianta 32:

d

2. a. b.

c. var a,b,c:integer;

begin

write(' a= '); read(a);

write(' b= '); read(b); 353v2115d

if a>b

then begin

c:=b; b:=a; a:=c;

end;

while a<=b do

begin

write(a,' ');

a:=a*2;

end;

write(a);

end.

d. citeste a,b

daca a>b atunci

│ c b; b a; a c

daca a<=b atunci

│ repeta

│ │ scrie a;

│ │ a a*2

│ pāna cānd a>b

scrie a

Varianta 33:

c

2. a. b.

c. var x,y,p:integer;

begin

write(' x= '); read(x);

write(' y= '); read(y);

p:=0;

repeat

if y mod 2 <>0

then p:=p+x;

y:= y div 2;

x:=x*2;

until y<1;

write(' p= ',p);

end.

d. citeste x,y

p x*y

scrie p

Varianta 34:

a

2. a.

b. 50 si 139 (oricare doua numere terminate in 0 si 9 sau 1 si 9)

c. var x,y,aux:integer;

begin

write(' x= '); read(x);

write(' y= '); read(y);

x:=x mod 10;

y:=y mod 10;

if y<x then begin

aux:=y;

y:=x;

x:=aux;

end;

while x<=y do

begin

write(x*10+y,' ');

x:=x+1;

y:=y-1;

end;

end.

d. citeste x,y

x x%10

y y%10

daca y<x atunci

│ aux y

│ y x

│ x aux

pentru i x,[(x+y)/2] executa

│ daca x≤y atunci

│ │ scrie x*10+y

│ x x+1

│ y y-1

Varianta 35:

c

2. a. s=4 b. 64 (suma puterilor factorilor primi sa fie =6)

c. var x,s,f,p:integer;

begin

write(' x= '); read(x);

s:=0;

f:=2;

while x>1 do

begin

p:=0;

while x mod f =0 do

begin

x:=x div f;

p:=p+1;

end;

if p<>0

then s:=s+p;

f:=f+1;

end;

write(' s= ',s);

end.

d.

Varianta 36:

b

2. a. b.

c. s

citeste v

daca v≠0 atunci

repeta

a v%10

b [v/10]%10

s s+a*10+b

citeste v

pāna cānd v=0

scrie s

d. var s,v,a,b:integer;

begin

s:=0;

write(' v= '); read(v);

while v<>0 do

begin

a:=v mod 10;

b:= v div 10 mod 10;

s:=s+a*10+b;

write(' v= '); read(v);

end;

write(' s= ',s);

end.

Varianta 37:

c

2. a. b. n=123 si k=5 (n -orice nr. iar k o cifra care nu este in n)

c. citeste n,k

nr 0; p

daca n≠0 atunci

repeta

c n%10

nr nr+c*p

p p*10

daca c=k atunci

nr nr+c*p

p p*10

n [n/10]

pāna cānd n=0

n nr

scrie n

d. var n,k,c,p,nr:longint;

begin

write(' n= '); read(n);

write(' k= '); read(k);

nr:=0; p:=1;

while n<>0 do

begin

c:=n mod 10;

nr :=nr+c*p;

p:=p*10;

if c=k then begin

nr:=nr+c*p;

p:=p*10;

end;

n:=n div 10;

end;

n:=nr;

write(' n= ',n);

end.

Varianta 38:

d

2. a. b. n=52931, k=2 (se afiseaza a k+1 cifra)

c. citeste n,k

pentru i k,1,-1 executa

n [n/10]

z n%10

scrie z

d. var n,k,i,z:integer;

begin

write(' n= '); read(n);

write(' k= '); read(k);

i:=k;

while i>0 do

begin

n:=n div 10;

i:=i-1;

end;

z:=n mod 10;

write(' z= ',z);

end.

Varianta 39:

b

2. a. b. 999 (orice nr cu toate cifrele 9)

c. citeste n

nr 0; p

daca n≠0 atunci

repeta

c n%10

daca c<9 atunci

c c+1

nr nr+c*p

p p*10

n [n/10]

pāna cānd n=0

n nr

scrie n

d. var n,nr,p,c:longint;

begin

write(' n= '); read(n);

nr:=0; p:=1;

while n<>0 do

begin

c:=n mod 10;

if c<9

then c:=c+1;

nr:=nr+c*p;

p:=p*10;

n:= n div 10;

end;

n:=nr;

write(' n= ',n);

end.

Varianta 40:

c

2. a. 2 si 7 b. 169 (oricie nr. prim la patrat)

c. citeste x

d 2; y 0; z

daca x≠1 atunci

repeta

│ p

│ daca x%d=0 atunci

│ │ repeta

│ │ │ p p+1

│ │ │ x [x/d]

│ │ pāna cānd x%d≠0

│ daca p≠0 atunci

│ │ daca y=0 atunci y d

│ │ z d

│ d d+1

pāna cānd x=1

scrie y

scrie z

d. var x,d,y,z,p:integer;

begin

write(' x= '); read(x);

d:=2; y:=0; z:=0;

while x<>1 do

begin

p:=0;

while x mod d=0 do

begin

p:=p+1;

x:=x div d;

end;

if p<>0

then begin

if y=0

then y:=d;

z:=d;

end;

d:=d+1;

end;

write(' y= ',y,' z= ',z);

end.

Varianta 41:

c

2. a. b.

c. diviz(x,d)

daca x%d=0 atunci

│ x [x/d]

│ scrie x

│ diviz(x,d)

citeste x

d

scrie x

cat timp x≥d executa

│ diviz(x,d)

│ d d+1

d. var x,d:integer;

begin

write(' x= '); read(x);

d:=2;

write(x,' ');

while x>=d do

begin

while x mod d =0 do

begin

x:=x div d;

write(x,' ');

end;

d:=d+1;

end;

end.

Varianta 42:

a

2. a. 5 (cmmdc) b.

c. citeste x,y

daca y>0 atunci

│ repeta

│ │ z x%y

│ │ x y

│ │ y z

│ pāna cānd y<=0

scrie x

d. var x,y,z:integer;

begin

write(' x= '); read(x);

write(' y= '); read(y);

while y>0 do

begin

z:=x mod y;

x:=y;

y:=z;

end;

write(' x= ',x);

end.

Varianta 43:

a

2. a. b.

c. citeste x,y

daca x*y≠0 atunci

│ repeta

│ │ daca x>y

│ │ │ atunci x x%y

│ │ │ altfel y y%x

│ pāna cānd x*y=0

scrie x+y

d. var x,y:integer;

begin

write(' x= '); read(x);

write(' y= '); read(y);

while x*y <>0 do

if x>y

then x:=x mod y

else y:=y mod x;

write(' x+y= ',x+y);

end.

Varianta 44:

a

2. a. b. 338 (orice nr de forma xy8 cu x,y din intervalul [1,9])

c. citeste x

y

daca x>y atunci

│ repeta

│ │ y y*10+9-x%10

│ pāna cānd x<=y

scrie y

d. var x,y:integer;

begin

write(' x= '); read(x);

y:=0;

while x>y do

y:=y*10+9-x mod 10;

write(' y= ',y);

end.

Varianta 45:

a

2. a. b.

c. citeste x,y

z

t

daca x≥z atunci

│ repeta

│ │ daca x%z=y atunci

│ │ │ t z

│ │ z z+1

│ pāna cānd x<z

scrie t

d. var x,y,z,t:integer;

begin

write(' x= '); read(x);

write(' y= '); read(y);

z:=1;

t:=0;

while x>=z do

begin

if x mod z = y

then t:=z;

z:=z+1;

end;

write(' t= ',t);

end.

Varianta 46:

c

2. a. b.

c. var n,s,nr:longint;

begin

write(' n= '); read(n);

s:=0;

nr:=0;

while n<>0 do

begin

if n mod 2 =0

then s:=s*10+n mod 10;

n:=n div 10;

end;

if s<>0

then nr:=1;

write(' nr= ',nr);

end.

d. citeste n

s

nr

daca n≠0 atunci

│ repeta

│ │ daca n%2=0 atunci

│ │ │ s s*10+n%10

│ │ n [n/10]

│ pāna cānd n=0

daca s≠0 atunci

│ nr

scrie nr

Varianta 47:

d

2. a. b.

c. citeste n

max

n [n/10]

daca max<n%10 atunci

│ max n%10

cat timp n≠0 executa

│ n [n/10]

│ daca max<n%10 atunci

│ │ max n%10

scrie max

d. var n, max:integer;

begin

write(' n= '); read(n);

max:=0;

repeat

n:= n div 10;

if max<n mod 10

then max:= n mod 10;

until n=0;

write(' max= ',max);

end.

Varianta 48:

a

2. a.

b. 105 506 904 303 (oricare 4 numere cu cifra zecilor 0)

c. citeste n

i

repeta

│ citeste x

│ nr

│ cat timp x>0 executa

│ │ nr nr*100+x%10

│ │ x [x/100]

│ cat timp nr>0 executa

│ │ x x*10+nr%10

│ │ nr [nr/10]

│ i i+1

│ scrie x

pana cand i>n

d. var n,i,nr,x:longint;

begin

write(' n= '); read(n);

for i:=1 to n do

begin

write(' x= '); read(x);

nr:=0;

while x>0 do

begin

nr:=nr*100+x mod 10;

x:=x div 100;

end;

while nr>0 do

begin

x:=x*10+nr mod 10;

nr:=nr div 10

end;

writeln(' x= ',x);

end;

end.

Varianta 49:

b

2. a. b. 92837 (in loc de 2 si 3 pot fi orice cifre)

c. citeste x

k

daca x≠0 atunci

│ repeta

│ │ k k*10+x%10

│ │ x [x/10]

│ pana cand x=0

daca k≠0 atunci

│ repeta

│ │ x x*10+k%10

│ │ k [k/100]

│ pana cand k=0

scrie x

d. var x,k:longint;

begin

write(' x= '); read(x);

k:=0;

while x<>0 do

begin

k:=k*10+x mod 10;

x := x div 10;

end;

while k<>0 do

begin

x:=x*10+k mod 10;

k:=k div 100;

end;

write(' x= ', x);

end.

Varianta 50:

b

2. a. b. 90 196 5293 95 (oricare 4 nr. Care au cifra zecilor 9)

c. citeste n

k

i

repeta

citeste x

c [x/10]%10

daca c<k atunci

k c

i i+1

pana cand i>n

scrie k

d. var n,i,k,c,x:integer;

begin

write(' n= '); read(n);

k:=9;

for i:=1 to n do

begin

write(' x= '); read(x);

c:=x div 10 mod 10;

if c<k

then k:=c;

end;

write(' k= ',k);

end.

Varianta 51:

d

2. a. b. 2468 (orice nr. cu toate cifrle pare)

c. citeste x

z

cat timp x≠0 executa

c x%10

daca c%2≠0 atunci

z z*10+c-1

altfel

z z*10+c

x [x/10]

scrie z

d. var x,z,c:integer;

begin

write(' x= '); read(x);

z:=0;

repeat

c:=x mod 10;

if c mod 2 <>0

then z:=z*10+c-1

else z:=z*10+c;

x:=x div 10;

until x=0;

write(' z= ',z);

end.

Varianta 52:

a

2. a.

b.

c. citeste n

d

c

i

repeta

citeste x

cat timp x%2=0 executa

x [x/2]; d d+1

cat timp x%5=0 executa

x [x/5]; c c+1

i i+1

pana cānd i>n

daca c<d

atunci scrie c

altfel d

d. var n,d,c,i,x:integer;

begin

write(' n= '); read(n);

d:=0;

c:=0;

for i:=1 to n do

begin

write(' x='); read(x);

while x mod 2=0 do

begin

x:=x div 2;

d:=d+1

end;

while x mod 5 =0 do

begin

x:=x div 5;

c:=c+1;

end;

end;

if c<d

then write(c)

else write(d);

end.

Varianta 53:

c

2. a. b. 2462 (orice nr. cu toate cifrele pare)

c. citeste x

z

p

cat timp x≠0 executa

c x%10

daca c%2≠0

atunci z z+c*p

p p*10

x [x/10]

scrie z

d. var x,z,p,c:integer;

begin

write(' x= '); read(x);

z:=0;

p:=1;

repeat

c:=x mod 10;

if c mod 2 <>0

then begin

z:=z+c*p;

p:=p*10;

end;

x:=x div 10;

until x=0;

write(' z= ',z);

end.

Varianta 54:

d

2. a. b. 1353 (orice nr cu toate cifrele impare)

c. citeste n

s

cāt timp n>0 executa

│ c n%10

│ daca c%2=0 atunci

│ │ p

│ │ i

│ │ repeta

│ │ │ p p*i

│ │ │ i i+1

│ │ pana cand i>c

│ │ s s+p

│ n [n/10]

scrie s

d. var n,s,c,p,i:integer;

begin

write(' n= '); read(n);

s:=0;

while n>0 do

begin

c:=n mod 10;

if c mod 2=0

then begin

p:=1;

for i:=2 to c do

p:=p*i;

s:=s+p;

end;

n:= n div 10;

end;

write(' s= ',s);

end.

Varianta 55:

a

2. a. k=3 b.

c. citeste n

citeste a

k

i

repeta

│ citeste b

│ daca a%10=b%10 atunci

│ │ k k+1

│ a b

│ i i+1

pana cand i>n

scrie k

d. var n,a,k,i,b:integer;

begin

write(' n= '); read(n);

write(' a= '); read(a);

k:=0;

for i:=2 to n do

begin

write(' b= '); read(b); 353v2115d

if a mod 10=b mod 10

then k:=k+1;

a:=b;

end;

write(' k= ',k);

end.

Varianta 56:

b

2. a. b. 1817 (orice nr de forma x8y7)

c. var n,r:longint;

begin

write(' n= '); read(n);

r:=0;

repeat

r:=(r*10+n mod 10)*10;

n:= n div 100;

until n<10;

write(' r= ',r);

end.

d. citeste n

r (n%10)*10

n [n/100]

cat timp n>=10 executa

│ r (r*10+n%10)*10

│ n [n/100]

scrie r

Varianta 57:

d

2. a. b. 63 70 77 91 98 (unul dintre ele)

c. var n,q,i:integer;

begin

write(' n= '); read(n);

q:=1;

i:=1;

while i< n div i do

begin

if n mod i =0

then q:=q+i;

i:=i+3;

end;

write(' q= ',q);

end.

d. citeste n

q

i

daca i<[n/i] atunci

│ repeta

│ │ daca n%i=0 atunci

│ │ │ q q+i

│ │ i i+3

│ pana cand i>=[n/i]

scrie q

Varianta 58:

c

2. a. b.

c. var n,q:integer;

begin

write(' n= '); read(n);

q:=1;

while n>0 do

begin

if n mod 5 =0

then q:=q*10

else q:=q*10+1;

n:=n div 5;

end;

write(' q= ',q);

end.

d. citeste n (numar natural)

q

daca n>0 atunci

repeta

│ daca n%5=0 atunci

│ │ q q*10

│ │altfel

│ │ q q*10+1

│ n [n/5]

pana cand n=0

scrie q

Varianta 59:

b

2. a. b. orice nr intre 30 si 39

c. var n,i:longint;

begin

write(' n= '); read(n);

repeat

n:=n mod 100 div 10 + n div 10;

until n<10;

write(' n= ',n);

end.

d. citeste n

n [(n%100)/10]+[n/10]

cat timp n>=0 executa

│ n [(n%100)/10]+[n/10]

scrie n

Varianta 60:

a

2. a. b. 24531 (orice nr care in fata lui 5 are numai cifre pare)

c. var n,c:longint;

begin

write(' n= '); read(n);

c:=10;

while n mod 2=1 do

begin

c:=n mod 10;

n:= n div 10;

end;

write(' c= ',c);

end.

d. citeste n (numar natural)

c

daca n%2=1 atunci

│ repeta

│ │ c n%10

│ │ n [n/10]

│ pana cand n%2≠1

scrie c

Varianta 61:

d

2. a. b.

c. var a,b,n,x,y:integer;

begin

write(' a= '); read(a);

write(' b= '); read(b); 353v2115d

n:=0;

while a<>b do

begin

x:=a mod 10;

y:=b mod 10;

if x<y

then n:=n*10+x

else n:=n*10+y;

a:=a div 10;

b:=b div 10;

end;

write(' n= ',n);

end.

d. citeste a,b

n

daca a≠b atunci

repeta

│ x a%10

│ y b%10

│ daca x<y atunci

│ │ n n*10+x

│ │ altfel

│ │ n n*10+y

│ a [a/10]

│ b [b/10]

pana cand a=b

scrie n

Varianta 62:

b

2. a. b. 1000 (orice p*10k , p [1,9]; k>3)

c. var x,aux,c,t:integer;

begin

write(' x= '); read(x);

aux:=x;

repeat

c:=x mod 10;

x:= x div 10;

t:=x;

if c=0

then aux:=x;

while t<>0 do

begin

c:=c*10;

t:=t div 10;

end;

x:=c+x;

write(' ',x);

until (x=aux) and (c<>0);

end.

d. citeste x

aux x

┌repeta

│ c x%10

│ x [x/10]

│ t x

│ daca c=0 atunci

│ │ aux x

│ daca t≠0 atunci

│ │ repeta

│ │ │ c c*10

│ │ │ t [t/10]

│ │ pana cand t=0

│ x c+x

│ scrie x

└pāna cānd x=aux si c≠0

Varianta 63:

a

2. a. b. 5 9 13 (oricare 3 nr nediviz cu 2)

c. var i,n,d,b,v,x,aux,a:integer;

begin

write(' n= '); read(n);

write(' d= '); read(d);

b:=0;

v:=0;

for i:=1 to n do

begin

write(' x= '); read(x);

a:=0;

aux:=x;

while x mod d = 0 do

begin

a:=a+1;

x:=x div d;

end;

if a>b

then begin

b:=a;

v:=aux;

end;

end;

write(v,' ',b);

end.

d. citeste n, d

b

v

pentru i 1,n executa

│ citeste x

│ a

│ aux x

│ daca x%d=0 atunci

│ │ repeta

│ │ │ a a+1

│ │ │ x [x/d]

│ │ pana cand x%d≠0

│ daca a>b atunci

│ │ b a

│ │ v aux

scrie v,' ',b

Varianta 64:

c

2. a. b.

c. var n,k,i,j:integer;

begin

write(' n= '); read(n);

k:=0;

for i:=1 to n do

for j:=1 to i do

begin

write(i+j,' ');

k:=k+1;

end;

write(k);

end.

d. citeste n

k

i

cat timp i<=n executa

│ j

│ cat timp j<=i executa

│ │ scrie i+j

│ │ k k+1

│ │ j j+1

│ i i+1

scrie k

Varianta 65:

b

2. a. b. 5555 si 7777 (orice nr cu 4 cifre identice)

c. var m,n,v,u,c:longint;

begin

write(' n= '); read(n);

m:=0; v:=n;

u:=n mod 10;

repeat

c:=n mod 10;

v:=v*10+c;

if c=u

then m:=m+1;

n:=n div 10;

until n=0;

write(v,' ',m);

end.

d. citeste n

m 0; v n

u n%10

c n%10

v v*10+c

daca c=u atunci

│ m m+1

n [n/10]

cat timp n≠0 executa

│ c n%10

│ v v*10+c

│ daca c=u atunci

│ │ m m+1

│ n [n/10]

scrie v, m

Varianta 66:

b

2. a. NU b. 25 13 50 69 0 (cite nr div cu 5 atatea nr nediv cu 5)

c. var n,x:integer;

begin

n:=0;

repeat

write(' x= '); read(x);

if x<>0 then

if x mod 5 = 0

then n:=n+1

else n:=n-1;

until x=0;

if n=0

then write('DA')

else write('NU');

end.

d. n

citeste x

cat timp x≠0 executa

│ daca x%5=0 atunci

│ │ n n+1

│ │ altfel

│ │ n n-1

│ citeste x

daca n=0 atunci

│ scrie "DA"

│ altfel

│ scrie "NU"

Varianta 67:

c

2. a. b. 7986 (orice nr cu toate cifrele mari de 5)

c. var n,z,c:longint;

begin

write(' n= '); read(n);

z:=0;

while n>0 do

begin

c:=n mod 10;

n:=n div 10;

if c<5

then z:=z*10+2*c;

end;

write(' z= ',z);

end.

d. citeste n (numar natural)

z

daca n>0 atunci

│ repeta

│ │ c n%10

│ │ n [n/10]

│ │ daca c<5 atunci

│ │ │ z z*10+2*c

│ pana cand n<=0

scrie z

Varianta 68:

a

2. a. b. 5 15 20 25 30 (5 nr. Nediviz cu 7)

c. var x,i,nr,n:integer;

begin

write(' x= '); read(x);

nr:=0;

for i:=1 to 5 do

begin

write(' n= '); read(n);

if n mod x=0

then

nr:=nr+1;

end;

write(' nr= ',nr);

end.

d. citeste x

nr

i

cat timp i<=5 executa

│ citeste n

│ daca n%x=0 atunci

│ │ nr nr+1

│ i i+1

scrie nr

Varianta 69:

d

2. a. b. 200 si 200 sau 200 si 100 sau 200 si 0

c. var x,y,t,u,z:integer;

begin

write(' x= '); read(x);

write(' y= '); read(y);

t:=0;

u:=1;

repeat

if x mod 10 > y mod 10

then z:=x mod 10

else z:=y mod 10;

t:=t+z*u;

u:=u*10;

x:= x div 10;

y:= y div 10;

until (x=0) and (y=0);

write(' t= ',t);

end.

d. citeste x,y

t

u

cat timp x≠0 sau y≠0 executa

│ daca x%10 > y%10 atunci

│ │ z x%10

│ │ altfel

│ │ z y%10

│ t t+z*u

│ u u*10

│ x [x/10]

│ y [y/10]

scrie t

Varianta 70:

a

2. a. b. n=5 x=2 (oricare 2 nr astfel incat n=2*x+1)

c. var x,y,n:integer;

begin

write(' x= '); read(x);

write(' y= '); read(y);

n:=0;

while x>=y do

begin

x:=x-y;

n:=n+1;

end;

write(' n= ',n,' x= ',x);

end.

d. citeste x,y

n

daca x>=y atunci

│ repeta

│ │ x x-y

│ │ n n+1

│ pana cand x<y

scrie n, x

Varianta 71:

c

2. a.

b. 42 35 296 1 (oricare 4 numere care au prima cifra 4 3 2 1 - in aceasta ordine)

c. var s,i,x,n,j:longint;

begin

s:=0;

write(' n= '); read(n);

for i:=1 to n do

begin

write(' x= '); read(x);

while x>9 do

x:=x div 10;

for j:=1 to i-1 do

x:=x*10;

s:=s+x;

end;

write(' s= ',s);

end.

d. s

citeste n (numar natural)

pentru i 1,n executa

│ citeste x

│ daca x>9 atunci

│ │ repeta

│ │ │ x [x/10]

│ │ pāna cānd x<=9

│ pentru j 1,i-1 executa

│ │ x x*10

│ s s + x

scrie s

Varianta 72:

d

2. a.

b. citeste n

pentru i 1,2*n-1 executa

│ b

│ j

│ cāt timp j-[i/2]>0 si i%2=1 executa

│ │ scrie "*"

│ │ j j-1

│ │ b

│ daca b <> 0 atunci

│ │ salt la rānd nou (sfārsit de rānd)

c. var n,i,b,j:integer;

begin

write(' n= '); read(n);

for i:=1 to 2*n-1 do

begin

b:=0;

if n-i<0

then j:=i-n

else j:=n-i;

while j>=0 do

begin

write('*');

j:=j-1;

b:=1;

end;

if b<>0

then writeln;

end;

end.

d. citeste n

pentru i 1,2*n-1 executa

│ b

│ j |n-i|

│ cāt timp j ≥ 0 executa

│ │ scrie "*"

│ │ j j-1

│ │ b

│ daca b = 0 atunci

│ │ salt la rānd nou (sfārsit de rānd)

Varianta 73:

c

2. a. b.

c. var a,b,p,nr,x,i:integer;

begin

write(' a= '); read(a);

write(' b= '); read(b); 353v2115d

write(' p= '); read(p);

nr:=0;

for i:=a to b do

begin

x:=i;

while (x<>0) and (x mod p <>0) do

x:=x div 10;

if x<>0

then nr:=nr+1;

end;

write(' nr= ',nr);

end.

d. citeste a, b, p

nr

┌ pentru i a,b executa

│ x i

│ daca x≠0 si x%p≠0 atunci

│ │ repeta

│ │ │ x [x/10]

│ │ pāna cānd x=0 sau x%p=0

│ daca x ≠ 0 atunci

│ │ nr nr+1

scrie nr

Varianta 74:

a

2. a. c=15 p=322

b. b=17335 (orice nr cu cifrele nesubliniate ca in exemplu)

c. var a,b,c,p:longint;

begin

write(' a= '); read(a);

write(' b= '); read(b); 353v2115d

c:=0;

p:=0;

while a+b>10 do

begin

if (a mod 10 = b mod 10) and (a mod 10 mod

then c:=c*10 + b mod 10

else p:=p*10 + a mod 10;

a:=a div 10;

b:=b div 10

end;

write(' c= ',c,' p= ',p);

end.

d. citeste a,b (numere naturale)

c

p

cāt timp a + b > 10 executa

│ daca (a%10 = b%10) si (a%10%2=1)

│ │ atunci c c + 1

│ │ altfel p p*10 + a%10

│ a [a/10]

│ b [b/10]

scrie c, p

Varianta 75:

d

2. a. b.

c. var a,k,x:longint;

begin

a:=0;

k:=0;

repeat

write(' x= '); read(x);

while x>99 do

x:=x div 10;

if x>9 then begin

a:=a*100+x;

k:=k+1;

end;

until k=4;

write(' a= ',a);

end.

d. a

k

cat timp k<4 executa

│ citeste x (numar natural)

│ cāt timp x > 99 executa

│ │ x [x/10]

│ daca x > 9 atunci

│ │ a a*100 + x

│ │ k k+1

scrie a

Varianta 76:

c

2. a. b. 6 (orice cifra para)

c. var a,x,p,c:integer;

begin

write(' a= '); read(a);

x:=2;

p:=1;

while a>1 do

begin

c:=0;

while a mod x =0 do

begin

c:=x;

a:= a div x;

end;

if c<>0

then p:=p*c;

x:=x+1;

end;

write(' p= ',p);

end.

d. citeste a (numar natural)

x

p

daca a>1 atunci repeta

│ │ c

│ │ daca x|a atunci repeta

│ │ │ │ c x

│ │ │ │ a [a/x]

│ │ │ pana cand not (x|a)

│ │ daca c≠0 atunci

│ │ │ p p*c

│ │ x x+1

│ pana cānd a<=1

scrie p

Varianta 77:

b

2. a.

b. 9 7 5 3 0 (orice sir de numere in ordine descrescatoare apoi 0)

c. var a,k,b:integer;

begin

write(' a= '); read(a);

k:=0;

while a<>0 do

begin

write(' b= '); read(b); 353v2115d

if a<b

then k:=k+1;

a:=b;

end;

write(' k= ',k);

end.

d. citeste a

k

daca a≠0 atunci

│ repeta

│ │ citeste b

│ │ daca a < b atunci

│ │ │ k k+1

│ │ a b

│ pāna cānd a=0

scrie k

Varianta 78:

a

2. a.

b. 15 53 59 42 0 (orice sir de numere in care ultima cifra a fiecarei perechi de

numere consecutive este distincta )

c. var a,k,b:integer;

begin

write(' a= '); read(a);

k:=0;

while a<>0 do

begin

write(' b= '); read(b); 353v2115d

if a mod 10 = b mod 10

then k:=k+1;

a:=b;

end;

write(' k= ',k);

end.

d. citeste a

k

daca a≠0 atunci

│ repeta

│ │ citeste b

│ │ daca a%10 = b%10 atunci

│ │ │ k k+1

│ │ a b

│ pāna cānd a=0

scrie k

Varianta 79:

d

2. a.

b. 13 (orice valoare la care suma divizorilor primi este egala cu numarul initial)

c. var a,x,k,c:integer;

begin

write(' a= '); read(a);

x:=2;

k:=0;

while a>1 do

begin

c:=0;

while a mod x = 0 do

begin

c:=x;

a:= a div x;

end;

if c<>0

then k:=k+x;

x:=x+1;

end;

write(' k= ',k);

end.

d. citeste a

x

k

daca a>1 atunci repeta

│ │ c

│ │ daca x|a atunci repeta

│ │ │ │ c x

│ │ │ │ a [a/x]

│ │ │ pāna cānd not (x|a)

│ │ daca c≠0 atunci

│ │ │ k k+x

│ │ x x+1

│ pāna cānd a<=1

scrie k

Varianta 80:

a

2. a. b. 5319 (oricenumar cu toate cifrele impare)

c. var a,b,p,c:longint;

begin

write(' a= '); read(a);

b:=0;

p:=1;

while a>0 do

begin

c:=a mod 10;

if c mod 2<>0

then begin

b:=b+p*c;

p:=p*10;

end;

a:=a div 10;

end;

write(' b= ',b);

end.

d. citeste a

b

p

daca a>0 atunci

│ repeta

│ │ c a%10

│ │ ┌daca c%2≠0 atunci

│ │ │ b b+p*c

│ │ │ p p*10

│ │ a [a/10]

│ pāna cānd a<=0

scrie b

Varianta 81:

b

2. a. aux=5 ok=0

b. 53827 (orice numar cu toate cifrele distincte si cea mai mare cifra 8)

c. var n,ok,aux:longint;

begin

write(' n= '); read(n);

ok:=1;

aux:=0;

while n>0 do

begin

if aux<=n mod 10 then

if aux=n mod 10

then ok:=0

else aux:=n mod 10;

n:=n div 10;

end;

write(' aux= ',aux,' ok= ',ok);

end.

d. citeste n

ok

aux

daca n>0 atunci

│ repeta

│ │ daca aux≤n%10 atunci

│ │ │ daca aux=n%10 atunci

│ │ │ │ ok

│ │ │ │ altfel

│ │ │ │ aux n%10

│ │ n [n/10]

│ pāna cānd n≤0

scrie aux,' ',ok

Varianta 82:

d

2. a. b.

c. var m,n,i,aux,ok,x:integer;

begin

write(' m= '); read(m);

write(' n= '); read(n);

for i:=1 to n do

begin

write(' x= '); read(x);

aux:=x;

ok:=0;

while x>0 do

begin

if x mod 10=m

then ok:=1;

x:=x div 10;

end;

if ok=1

then write(' aux= ',aux);

end;

end.

d. citeste m

citeste n

pentru i 1,n executa

│ citeste x

│ aux x

│ ok

│ daca x>0 atunci

│ │ repeta

│ │ │ daca x%10=m atunci

│ │ │ │ ok

│ │ │ x [x/10]

│ │ pana cand x<=0

│ daca ok=1 atunci

│ │ scrie aux

Varianta 83:

a

2. a. NU b.

c. var x,aux,ok1:integer;

begin

write(' x= '); read(x);

aux:=x;

ok1:=1;

while x>=10 do

begin

if x mod 10 > x div 10 mod 10

then ok1:=0;

x:=x div 10;

end;

if ok1=1

then write(aux)

else write('NU');

end.

d. citeste x

aux x

ok1

daca x≥10 atunci

│ repeta

│ │ daca x%10>[x/10]%10 atunci

│ │ │ ok1

│ │ x [x/10]

│ pana cand x<0

daca ok1=1 atunci

│ scrie aux

│ altfel

│ scrie "nu"

Varianta 84:

c

2. a. 6 NU b.

c. var n,ok1,c:integer;

begin

write(' n= '); read(n);

ok1:=0;

while n>0 do

begin

c:=n mod 10;

if (c>5) and (c mod 2 = 0)

then ok1:=1

else ok1:=0;

if ok1=1

then begin

write(c,' ');

ok1:=1;

end;

n:=n div 10;

end;

if ok1=0

then write('NU');

end.

d. citeste n

ok1

daca n>0 atunci

│ repeta

│ │ c n%10

│ │ daca c>5 si c%2=0 atunci

│ │ │ ok1

│ │ │ altfel

│ │ │ ok1

│ │ daca ok1=1 atunci

│ │ │ scrie c, ' '

│ │ │ ok1

│ │ n [n/10]

│ pana cand n≤0

daca ok1=0 atunci

│ scrie "nu"

Varianta 85:

a

2. a. b.

c. var n,ok1,ok,c:integer;

begin

write(' n= '); read(n);

ok:=0;

while n>0 do

begin

c:=n mod 10;

if c mod 2 = 1

then ok1:=1

else ok1:=0;

if ok1=1

then begin

write(c,' ');

ok:=1;

end;

n:=n div 10;

end;

if ok=0

then write('NU');

end.

d. citeste n

ok

daca n>0 atunci

│ repeta

│ │ c n%10

│ │ daca c%2=1 atunci

│ │ │ ok1

│ │ │ altfel

│ │ │ ok1

│ │ daca ok1=1 atunci

│ │ │ scrie c

│ │ │ ok

│ │ n [n/10]

│ pana cand n≤0

daca ok=0 atunci

│ scrie "nu"

Varianta 86:

c

2. a. b. 25 (orice nr mai mare ca 20)

c. var n,k,i:integer;

begin

write(' n= '); read(n);

write(' k= '); read(k);

for i:=1 to n do

if i div k=0

then write(i,' ')

else write(i mod k,' ');

end.

d. citeste n, k

i

daca i<=n atunci

│ repeta

│ │ daca [i/k]=0 atunci

│ │ │ scrie i

│ │ │altfel

│ │ │ scrie i%k

│ │ i i+1

│ pana cand i>n

Varianta 87:

d

2. a. b.

c. var a,b,c,x:integer;

begin

write(' a= '); read(a);

write(' b= '); read(b); 353v2115d

write(' c= '); read(c);

while (a<>b) or (a<>c) do

begin

x:=a;

if x>b

then x:=b;

if x>c

then x:=c;

if x<>a

then a:=a-x;

if x<>b

then b:=b-x;

if x<>c

then c:=c-x;

end;

write(' a= ',a);

end.

d. citeste a,b,c

daca a≠b sau a≠c atunci

│ repeta

│ │ x a

│ │ daca x>b atunci

│ │ │ x b

│ │ daca x>c atunci

│ │ │ x c

│ │ daca x≠a atunci

│ │ │ a a-x

│ │ daca x≠b atunci

│ │ │ b b-x

│ │ daca x≠c atunci

│ │ │ c c-x

│ pana cand a=b si a=c

scrie a

Varianta 88:

b

2. a. b.

c. var a,p,b,c:longint;

begin

write(' a= '); read(a);

p:=1;

b:=0;

while a<>0 do

begin

c:=a mod 10;

if a mod 2=0

then b:=b+c*p

else b:=b*10+c;

a:=a div 10;

p:=p*10;

end;

write(' b= ',b);

end.

d. citeste a

p

b

daca a≠0 atunci

│ repeta

│ │ c a%10

│ │ daca a%2=0 atunci

│ │ │ b b+c*p

│ │ │altfel

│ │ │ b b*10+c

│ │ a [a/10]

│ │ p p*10

│ pana cand a=0

scrie b

Varianta 89:

a

2. a. b.

c. var n,t,r:longint;

begin

write(' n= '); read(n);

t:=n; r:=0;

while t>0 do

begin

if t mod 10 mod 2 =1

then r:=r*10+1

else r:=r*10+t mod 10;

t:=t div 10

end;

n:=0;

while r>0 do

begin

n:=n*10+r mod 10;

r:= r div 10;

end;

write(' n= ',n);

end.

d. citeste n

t n; r

daca t>0 atunci

│ repeta

│ │┌daca (t%10)%2=1 atunci

│ ││ r r*10+1

│ ││altfel

│ ││ r r*10+t%10

│ │ t [t/10]

│ pana cand t<=0\

n

daca r>0 atunci

│ repeta

│ │ n n*10+r%10

│ │ r [r/10]

│ pana cand r<=0

scrie n

Varianta 90:

c

2. a.

b. 25 29 2 si 451 457 9 (orice numere astfel incat nici un numar din

intervalul[a,b] sa nu aiba ultima cifra k)

c. var a,b,k,t,p:integer;

begin

write(' a= '); read(a);

write(' b= '); read(b); 353v2115d

write(' k= '); read(k);

t:=a;

p:=0;

while t<=b do

begin

if k=t mod 10

then begin

write(t,' ');

p:=1;

end;

t:=t+1;

end;

if p=0

then write(-1);

end.

d. citeste a, b, k

t a

p

daca t≤b atunci

│ repeta

│ │ daca k=t%10 atunci

│ │ │ scrie t

│ │ │ p

│ │ t t+1

│ pana cand t>b

daca p=0 atunci

│ scrie -1

Varianta 91:

d

2. a. 7

b. citeste z

z |z|

x

y x

x [(x+z/x)/2]

cat timp x≠y executa

│ y x

│ x [(x+z/x)/2]

scrie x

c. var z,x,y:integer;

begin

write(' z= '); read(z);

z:= abs(z);

x:=1;

repeat

y:=x;

x:=(x+z div x) div 2;

until x=y;

write(' x= ',x);

end.

d. o singura data

Varianta 92:

a

2. a. b. 5 9 2 (oricare 3 numere din intervalul [1,10])

c. var n,nr,y,i,x:integer;

begin

write(' n= '); read(n);

nr:=0;

y:=0;

for i:=1 to n do

begin

repeat

write(' x= '); read(x);

nr:=nr+1;

until (x>=1) and (x<=10);

y:=y+x;

end;

write(y div n,' ');

write(nr);

end.

d. citeste n

nr

y

pentru i 1,n executa

│ citeste x (numar real)

│ nr nr+1

│ cat timp x<1 sau x>10 executa

│ │ citeste x (numar real)

│ │ nr nr+1

│ y y+x

scrie [y/n]

scrie nr

Varianta 93:

b

2. a.

b. var n,m,s:integer;

begin

write(' n= '); read(n);

write(' m= '); read(m);

s:=0;

while n<m do

begin

s:=s+n;

n:=n+3;

end;

if n=m

then write(s+n)

else write(0);

end.

c. 7 valori (m= 0 2 3 5 6 8 9)

d.

k [(m-n)/3]

daca (m-n)%3 ≠ 0

│ atunci scrie 0

│ altfel scrie n+n*[(m-n)/3]+[k*(k+1)/2]*3

Varianta 94:

a

2. a. b.

c. citeste n

n1

n2

k1

p

cāt timp n ≠ 0 executa

│ daca (n%10)%2=0 atunci

│ │ n2 n2 * 10 + n%10

│ │ altfel

│ │ n1 n1 * 10 + n%10

│ │ p p*10

│ n [n/10]

x n2*p + n1

scrie x

d. var n,n1,n2,k1,p,x,i:longint;

begin

write(' n= '); read(n);

n1:=0;

n2:=0;

k1:=0;

while n<>0 do

begin

if (n mod 10) mod 2 =0

then n2:=n2*10+n mod 10

else begin

n1:=n1*10+n mod 10;

k1:=k1+1;

end;

n:=n div 10

end;

p:=1;

for i:=1 to k1 do

p:=p*10;

x:=n2*p+n1;

write(' x= ',x);

end.

Varianta 95:

d

2. a. b.

c. var x,n,k:longint;

begin

x:=0;

write(' n= '); read(n);

write(' k= '); read(k);

while n<>0 do

begin

if n mod 10< k

then x:=x*10+n mod 10;

n:=n div 10;

end;

write(' x= ',x);

end.

d. x

citeste n,k

daca n≠0 atunci

│ repeta

│ │ daca n mod 10<k atunci

│ │ │ x x*10 + n mod 10

│ │ n [n/10]

│ pana cand n=0

scrie x

Varianta 96:

c

2. a.

b. 30 (orice nr multiplu de 3)

c. var n,i,j,k:integer;

begin

write(' n= '); read(n);

for i:=1 to n do

for j:=1 to n do

for k:=1 to n do

if (i<j) and (j<k)

then if i+j+k=n

then begin

write(i,' ',j,' ',k);

writeln;

end;

end.

d. citeste n

pentru i 1,n executa

│ pentru j 1,n executa

│ │ k n-(i+j)

│ │ daca i<j<k atunci

│ │ │ scrie i,' ',j,' ',k

│ │ │ salt la rānd nou

Varianta 97:

b

2. a.

b. 27 44 123 (ultima cifra, de la primul nr, ultima cifra, de la al doilea nr, *2 si

ultima cifra, de la ultimu nr, *3 sa fie consecutive)

c. citeste x

s x % 10

scrie s

citeste x

s (x % 10)*2

scrie s

citeste x

s (x % 10)*3

scrie s

d. var i,s,x,j:integer;

begin

for i:=1 to 3 do

begin

write(' x= '); read(x);

s:=0;

for j:=1 to i do

s:=s+x mod 10;

write(s);

end;

end.

Varianta 98:

d

2. a. b.

c. citeste n

i n

scrie i

d. var n,i:integer;

begin

write(' n= '); read(n);

i:=1;

while i*i<=n do

i:=i+1;

write( i-1 );

end.

Varianta 99:

d

2. a. b.

c. putere(p,x)

daca x>0

│ atunci

│ putere(p,x-1);

│ p (4*p)%10;

│ altfel p

citeste x

p

putere(p,x)

scrie p

d. var x,p,i:integer;

begin

write(' x= '); read(x);

p:=1;

for i:=1 to x do

p:=(p*4) mod 10;

write(' p= ',p);

end.

Varianta 100:

1. a

2. a. b.

Sau secventa:

citeste x

daca x % 2 =0

│ atunci p

│ altfel p

scrie p;

Varianta 1:

c d

v1:=A.x-B.x;

v2:=A.y-B.y;

d:=sqrt(v1*v1+v2*v2);

write(' d= ',d);

Nodul cu cei mai multi fii este 6

Frunzele arborelui sunt nodurile: 1 2 3 8

var i, j, n, m:integer;

a:array[1..10,1..10]of integer;

begin

write(' n= '); read(n);

write(' m= '); read(m);

for i:=1 to n do

for j:=1 to m do

if i<j

then a[i,j]:=i

else a[i,j]:=j;

for i:=1 to n do

begin

for j:=1 to m do

write(a[i,j]:3);

writeln;

end;

end.

Varianta 2:

a c 5 si 2

if a[k,j] mod 2 = 1

then s := s + a[k,j];

var i:integer;

cuv:string[21];

begin

write(' cuvantul: '); readln(cuv);

for i:=1 to length(cuv) do

cuv[i]:=upcase(cuv[i]);

write(cuv);

end.

Varianta 3:

f.x:=f1.x*f2.y+f1.y*f2.x;

f.y:=f1.y*f2.y;

var n,i,j:integer;

a:array[1..10,1..10]of integer;

begin

write(' n= '); read(n);

for i:=1 to n do

for j:=1 to n do

begin

a[i,j]:=n-j+1;

if (i=j)

then a[i,j]:=0;

end;

for i:=1 to n do

begin

for j:=1 to n do

write(a[i,j]:4);

writeln;

end;

Varianta 4:

b a

if (s[i]>='a') and (s[i]<='z')

then s[i]:='W';

var n,i,j:integer;

a:array[1..10,1..10]of integer;

begin

write(' n= '); read(n);

for i:=1 to n do

for j:=1 to n do

begin

a[i,j]:=n-i+1;

if (i+j=n+1)

then a[i,j]:=0;

end;

for i:=1 to n do

begin

for j:=1 to n do

write(a[i,j]:4);

writeln;

end;

end.

Varianta 5:

b d 14 frunze

if s[i]=c

then s[i]:=d;

var n,m,i,j:integer;

a:array[1..10,1..10]of integer;

begin

write(' n= '); read(n);

write(' m= '); read(m);

for i:=1 to n do

for j:=1 to m do

begin

if (i<j)

then a[i,j]:=j

else a[i,j]:=i;

end;

for i:=1 to n do

begin

for j:=1 to m do

write(a[i,j]:4);

writeln;

end;

end.

Varianta 6:

a c 14 muchii

var i:integer;

s:string;

begin

write(' textul: '); readln(s);

for i:=2 to length(s) do

if (s[i-1]=' ') and (s[i]<>' ')

then s[i]:=upcase(s[i]);

if s[1]<>' ' then s[1]:=upcase(s[i]);

write(s);

end.

Varianta 7:

a d

write(x.nume,' ');

write(x.clasa,' ');

write(x.media);

2 muchii

var i:integer;

c:char;

s:string;

begin

write(' textul: '); readln(s);

for i:=1 to length(s) do

if (s[i]<>'a') and (s[i]<>'e') and (s[i]<>'i') and (s[i]<>'o') and (s[i]<>'u')

then c:=s[i];

write(' ultima consoana: ',c);

end.

Varianta 8:

c a abefgh 6

var n, p, i, j, k:integer;

a:array[1..10,1..10] of integer;

begin

write(' n= '); read(n);

write(' p= '); read(p);

k:=-1;

for i:=1 to n do

for j:=1 to p do

begin

k:=k+2;

a[i,j]:=k*k;

end;

for i:=1 to n do

begin

for j:=1 to p do

write(a[i,j]:4);

writeln;

end;

end.

Varianta 9:

c a abcdea

var n,i,j,s:integer;

a:array[1..10,1..10]of integer;

begin

write(' n= '); read(n);

for i:=1 to n do

for j:=1 to n do

begin

write(' A[',i,',',j,']= ');

read(a[i,j]);

end;

s:=0;

for i:=1 to n do

write(a[1,i],' ');

for i:=2 to n-1 do

write(a[i,n],' ');

for i:=n downto 1 do

write(a[n,i],' ');

for i:=n-1 downto 2 do

write(a[i,1],' ');

end.

Varianta 10:

a c

var n,p,i,j,k:integer;

a:array[1..10,1..10] of integer;

begin

write(' n= '); read(n);

write(' p= '); read(p);

k:=-2;

for i:=1 to n do

for j:=1 to p do

begin

k:=k+2;

a[i,j]:=k*k;

end;

for i:=1 to n do

begin

for j:=1 to p do

write(a[i,j]:4);

writeln;

end;

end.

Varianta 11:

a d 11 brcdbr

var n,m,i,j,min:integer;

a:array[1..10,1..10] of integer;

begin

write(' m= '); read(m);

write(' n= '); read(n);

for i:=1 to m do

for j:=1 to n do

begin

write(' A[',i,',',j,']= ');

read(a[i,j]);

end;

for i:=1 to m do

begin

min:=a[i,1];

for j:=2 to n do

if min>a[i,j]

then min:=a[i,j];

write(min,' ');

end;

end.

Varianta 12:

b a 11 AbcdEfghOId

var e:record

nume:string[30];

nota1, nota2, nota3:integer;

end;

var n,i,j:integer;

a:array[1..10,1..10]of integer;

begin

write(' n= '); read(n);

for i:=1 to n do

for j:=1 to n do

if i+j=n+1

then a[i,j]:=0

else if i+j<n+1

then a[i,j]:=i

else a[i,j]:=n-j+1;

for i:=1 to n do

begin

for j:=1 to n do

write(a[i,j]:4);

writeln;

end;

end.

Varianta 13:

c b 11 bcdfghd

var m:record

nume:string[30];

pret:real;

end;

var n,i,j:integer;

a:array[1..10,1..10]of integer;

begin

write(' n= '); read(n);

for i:=1 to n do

for j:=1 to n do

if i+j=n+1

then a[i,j]:=0

else if i+j<n+1

then a[i,j]:=1

else a[i,j]:=2;

for i:=1 to n do

begin

for j:=1 to n do

write(a[i,j]:4);

writeln;

end;

end.

Varianta 14:

b c

var n,i,j:integer;

a:array[1..4,1..4]of integer;

begin

write(' n= '); read(n);

for j:=1 to 4 do

begin

for i:=1 to 4 do

a[i,j]:=n mod 10;

n:=n div 10;

end;

for i:=1 to 4 do

begin

for j:=1 to 4 do

write(a[i,j]:2);

writeln;

end;

end.

Varianta 15:

c d bemeut

Gradul minim este: 2

var n,i,j:longint;

a:array[1..5,1..5]of integer;

begin

write(' n= '); read(n);

for i:=1 to 5 do

begin

for j:=1 to 5 do

a[i,j]:=n mod 10;

n:=n div 10;

end;

for i:=1 to 5 do

begin

for j:=1 to 5 do

write(a[i,j]:2);

writeln;

end;

end.

Varianta 16:

b a

Numarul minim este 2, iar īn vārful stivei va ramane elementul 7

clasa a-XII-a A

clasaaa

var n,i,j:longint;

a:array[1..50,1..50]of integer;

begin

write(' n= '); read(n);

for i:=1 to n do

for j:=1 to n do

if (i=j) or (i+j=n+1)

then a[i,j]:=4

else a[i,j]:=3;

for i:=1 to n do

begin

for j:=1 to n do

write(a[i,j]:3);

writeln;

end;

end.

Varianta 17:

a b

Numarul minim este 3 iar īn stiva mai ramāne un element.

b*t

var n,i,j:longint;

a:array[1..20,1..20]of integer;

begin

write(' n= '); read(n);

for i:=1 to n do

for j:=1 to n do

a[i,j]:=i+j-1;

for i:=1 to n do

begin

for j:=1 to n do

write(a[i,j]:3);

writeln;

end;

end.

Varianta 18:

c a Īn vārful stivei este 2 iar in stiva sunt 3 elemente.

a:='informatica';

for i:=1 to length(a) do

if (s[i]='a') or (s[i]= 'e') or (s[i]='i') or (s[i]='o') or (s[i]='u')

then

write(

else

write(a[i]

var n,i,j:longint;

a:array[1..20,1..20]of integer;

begin

write(' n= '); read(n);

for i:=1 to n do

for j:=1 to n do

if i mod 2=1

then a[i,j]:=i

else a[i,j]:=j;

for i:=1 to n do

begin

for j:=1 to n do

write(a[i,j]:3);

writeln;

end;

end.

Varianta 19:

a c 2008bac2008 5 si 4

var n,i,j:longint;

a:array[1..20,1..20]of integer;

begin

write(' n= '); read(n);

for i:=1 to n do

for j:=1 to n do

if j mod 2=1

then a[i,j]:=i+j

else a[i,j]:=i;

for i:=1 to n do

begin

for j:=1 to n do

write(a[i,j]:3);

writeln;

end;

end.

Varianta 20:

d a 9 si 7

a:='Bac 2008 iulie';

for i:=length(a) downto do

write(a[i]);

var n,i,j:longint;

a:array[1..20,1..20]of integer;

begin

write(' n= '); read(n);

for i:=1 to n do

for j:=1 to n do

if (i=1) or (j=1)

then a[i,j]:=i+j

else a[i,j]:=a[i,j-1]+a[i-1,j];

for i:=1 to n do

begin

for j:=1 to n do

write(a[i,j]:4);

writeln;

end;

end.

Varianta 21:

d c ev.data_nasterii.an

var s:string[250];

i:integer;

begin

write(' Textul: '); read(s);

for i:=1 to length(s)-1 do

if s[i]=s[i+1]

then writeln(s[i],s[i+1]);

end.

Varianta 22:

b a

var m,n,i,j,k:integer;

a:array[1..100,1..100]of integer;

begin

write(' m= '); read(m);

write(' n= '); read(n);

k:=m*n;

for i:=1 to m do

for j:= 1 to n do

begin

a[i,j]:=k;

k:=k-1;

end;

for i:=1 to m do

begin

for j:=1 to n do

write(a[i,j]:3);

writeln;

end;

end.

Varianta 23:

b d lantul maxim are 3 muchii

var m,n,i,j:integer;

a:array[1..100,1..100]of integer;

begin

write(' m= '); read(m);

write(' n= '); read(n);

for i:=1 to m do

for j:= 1 to n do

if (i=1) or(j=1)

then a[i,j]:=i+j-1

else a[i,j]:=a[i-1,j]+a[i,j-1];

write('Elementul solicitat este: ',a[m,n]);

end.

Varianta 24:

a c delete(s,1,2);

for i:=1 to n do

for j:= 1 to n do

begin

a[i,j]:=(i+j-1) mod n;

if (a[i,j]=0)

then a[i,j]:=n

end;

var s1,s2,s:string[100];

i,j:integer;

begin

write(' Cuvantul 1: '); readln(s1);

write(' Cuvantul 2: '); readln(s2);

i:=length(s1);

j:=length(s2);

while (i>0) and (j>0) and (s1[i]=s2[j]) do

begin

i:=i-1;

j:=j-1;

end;

s:=copy(s1,i+1,length(s1)-i+1);

write(' sufixul: ',s);

end.

Varianta 25:

c d y:= sqrt(x)+1/x+abs(x);

ok:=false;

for i:=1 to length(s) do

if (s[i]>='0') and (s[i]<='9')

then ok:=true;

if ok

then write(' CORECT')

else write(' INCORECT');

var m,n,i,j,p,max:integer;

a:array[1..100,1..100]of integer;

begin

write(' m= '); read(m);

write(' n= '); read(n);

for i:=1 to m do

for j:= 1 to n do

begin

write(' A[',i,',',j,']= ');

read(a[i,j]);

end;

for j:=1 to n do

begin

p:=a[1,j];

for i:= 2 to m do

p:=p*a[i,j];

if p> max

then max:=p;

end;

for j:=1 to n do

begin

p:=a[1,j];

for i:= 2 to m do

p:=p*a[i,j];

if p = max

then write(j,' ');

end;

end.

Varianta 26:

d c roton 4. 4 elem.

var n,i,j,p,k:integer;

a:array[1..100,1..100]of integer;

begin

write(' n= '); read(n);

for i:=1 to n do

for j:= 1 to n do

begin

write(' A[',i,',',j,']= ');

read(a[i,j]);

end;

for i:=1 to n do

for j:= 1 to n do

begin

p:=1;

for k:=1 to n do

if k<>i then p:=p*a[k,j];

if p=a[i,j]

then write(p,' ');

end;

end.

Varianta 27:

a b

H.x:=F.x*G.y+F.y*G.x;

H.y:=F.y*G.y;

var n,i,j:integer;

a:array[1..100,1..100]of integer;

begin

write(' n= '); read(n);

for i:=1 to n do

for j:= 1 to n do

if (i=1) or (j=1) or (j=n)

then a[i,j]:=1

else a[i,j]:=a[i-1,j-1]+a[i-1,j]+a[i-1,j+1];

for i:=1 to n do

begin

for j:= 1 to n do

write(a[i,j]:4);

writeln;

end;

end.

Varianta 28:

b c

var s1,s2:string[20];

i:integer;

begin

write(' s1= '); readln(s1);

s2:=s1;

for i:=1 to length(s2) do

if s2[i]='a'

then delete(s2,i,1);

if s1<>s2 then writeln(s2);

s2:=s1;

for i:=1 to length(s2) do

if s2[i]='e'

then delete(s2,i,1);

if s1<>s2 then writeln(s2);

s2:=s1;

for i:=1 to length(s2) do

if s2[i]='i'

then delete(s2,i,1);

if s1<>s2 then writeln(s2);

s2:=s1;

for i:=1 to length(s2) do

if s2[i]='o'

then delete(s2,i,1);

if s1<>s2 then writeln(s2);

s2:=s1;

for i:=1 to length(s2) do

if s2[i]='u'

then delete(s2,i,1);

if s1<>s2 then writeln(s2);

end.

Varianta 29:

a d atac 4.

var n,i,j:integer; pp,p:real;

ok:boolean;

a:array[1..6,1..6]of integer;

begin

write(' n= '); read(n);

for i:=1 to n do

for j:= 1 to n do

begin

write(' A[',i,',',j,']= ');

read(a[i,j]);

end;

pp:=1;

for j:=1 to n do

begin

p:=a[1,j] / a[1,1];

ok:=true;

for i:=2 to n do

if a[i,j]/a[i,1]<>p

then ok:=false;

if (ok) and (frac(p)=0)

then pp:=pp*p;

end;

write(pp:5:0,' ');

end.

Varianta 30:

c a

var n,i,j:integer;

a:array[1..20,1..20] of integer;

begin

write(' n= '); read(n);

for i:=1 to n do

for j:=1 to n do

if (i=1) or (j=1)

then a[i,j]:=1

else a[i,j]:=a[i,j-1]+a[i-1,j];

for i:=1 to n do

begin

for j:=1 to n do

write(a[i,j]:4);

writeln;

end;

end.

Varianta 31:

c b

type masina=record

marca:string[20];

anul_fabricatiei:integer;

end;

var i,j,s:integer;

a:array[1..20,1..20] of integer;

begin

for i:=1 to 10 do

for j:=1 to 7 do

begin

write(' a[',i,',',j,']= ');

read(a[i,j]);

end;

s:=0;

for i:=1 to 7 do

s:=s+a[1,i];

for i:=2 to 9 do

s:=s+a[i,7];

for i:=7 downto 1 do

s:=s+a[10,i];

for i:=9 downto 2 do

s:=s+a[i,1];

write(' s= ',s);

end.

varf 200

varf 6 6

Varianta 32:

b d

var c1,c2:char;

s:string;

i:integer;

begin

write(' c1= '); readln(c1);

write(' c2= '); readln(c2);

write(' s= '); readln(s);

writeln(s);

for i:=1 to length(s) do

begin

if s[i]=c1

then s[i]:=c2

else if s[i]=c2

then s[i]:=c1;

end;

writeln(s);

end.

Varianta 33:

a c

type cerc=record

x,y:integer;

raza:real

end;

var x:cerc;

var s:string[255];

lit:array[0..40]of byte;

i,cuv:integer;

c:char;

begin

write(' s= '); readln(s);

if s[1]=' '

then cuv:=0

else cuv:=1;

for i:=2 to length(s) do

if (s[i-1]=' ') and (s[i]<>' ')

then cuv:=cuv+1;

writeln(' cuv= ',cuv);

for i:=1 to length(s) do

if (s[i]<>' ')

then inc( lit[ord(s[i])-ord('A')] );

for c:='B' to 'Z' do

if (c <>'E')and(c <>'I')and(c <>'O')and (c <>'U')

then if (lit[ord(c)-ord('A')]<>0)

then write(c,' ');

end.

Varianta 34:

b c asta

var n,i,j,k:integer;

a:array[1..20,1..20]of integer;

begin

write(' n= '); read(n);

k:=0;

for i:=1 to n do

for j:=1 to n do

begin

if k mod 3=0

then k:=k+2;

a[i,j]:=k;

k:=k+2;

end;

for i:=1 to n do

begin

for j:=1 to n do

write(a[i,j]:4);

writeln;

end;

end.

Varianta 35:

d c

amat

Graful are 5 componente conexe.

Trebuie adaugate 4 muchii ca graful sa devina conex.

var n,i,j,min:integer;

a:array[1..100,1..100]of integer;

begin

write(' n= '); read(n);

for i:=1 to n do

for j:=1 to n do

begin

write(' A[',i,',',j,']= ');

read(a[i,j]);

end;

for j:=1 to n do

begin

min:=a[1,j];

for i:=1 to n do

if a[i,j]<min

then min:=a[i,j];

write(min,' ');

end;

end.

Varianta 36:

a b

var n,m,i,j,min:integer;

a:array[1..100,1..100]of integer;

begin

write(' n= '); read(n);

write(' m= '); read(m);

for i:=1 to n do

for j:=1 to m do

begin

write(' A[',i,',',j,']= ');

read(a[i,j]);

end;

for j:=1 to m do

begin

min:=a[1,j];

for i:=1 to n do

if a[i,j]<min

then min:=a[i,j];

write(min,' ');

end;

end.

Varianta 37:

b a d-(1)=2; d+(5)=2

var s:string[255];

lit:array[0..40]of byte;

i,cuv:integer;

c:char;

begin

write(' s= '); readln(s);

if s[1]<>' '

then s[1]:=upcase(s[1]);

for i:=2 to length(s) do

begin

if (s[i-1]=' ') and (s[i]<>' ')

then s[i]:=upcase(s[i]);

if (s[i-1]<>' ') and (s[i]=' ')

then s[i-1]:=upcase(s[i-1]);

end;

if s[length(s)]<>' '

then s[length(s)]:=upcase(s[length(s)]);

writeln(' s= ',s);

end.

Varianta 38:

d c 2 muchii 6 cicluri

var n,i,j,p,imin:integer;

a:array[1..30,1..30]of integer;

begin

write(' n= '); read(n);

for i:=1 to n do

for j:=1 to n do

begin

write(' A[',i,',',j,']= ');

read(a[i,j]);

end;

p:=1;

for j:=1 to n do

begin

imin:=1;

for i:=1 to n do

if a[i,j]<a[imin,j]

then imin:=i;

if a[imin,j]=a[n+1-j,j]

then p:=p*a[imin,j];

end;

write(' p= ',p);

end.

Varianta 39:

c a 3 componente conexe

var s:string[255];

i,j,i1:integer;

aux:char;

begin

write(' s= '); read(s);

if ( s[1]='a' ) or ( s[1]='e' ) or ( s[1]='i' ) or ( s[1]='o' ) or ( s[1]='u' )

then begin

j:=i;

while (s[j+1]<>' ')and (j<length(s)) do

j:=j+1;

i1:=1;

while i1<j do

begin

aux:=s[i1];

s[i1]:=s[j];

s[j]:=aux;

i1:=i1+1; j:=j-1;

end;

end;

for i:=0 to length(s) do

if (s[i-1]=' ')and (s[i]<>' ')

then if (s[i]='a') or (s[i]='e') or (s[i]='i') or (s[i]='o') or (s[i]='u')

then begin

j:=i;

while ( s[j+1]<>' ' ) and ( j<length(s) ) do

j:=j+1;

i1:=i;

while i1<j do

begin

aux:=s[i1];

s[i1]:=s[j];

s[j]:=aux;

i1:=i1+1; j:=j-1;

end;

end;

write(' s= ',s);

end.

Varianta 40:

a d 3 componente conexe

var s,s1:string[255];

p,i:integer;

begin

write(' s= '); read(s);

i:=1;

while s[i]<>'*' do

begin

s1:=s1+s[i];

i:=i+1;

end;

write(s1,' ');

repeat

p:=pos(s1,s);

if p>0

then delete(s,p,length(s1));

until p=0;

write(' s= ',s);

end.

Varianta 41:

a a Nodurile 1,3,5,7,9 sunt frunze abc

var n,i,j:integer;

a:array[1..30,1..30]of integer;

begin

write(' n= '); read(n);

for i:=1 to n do

for j:=1 to n do

a[i,j]:=i+j;

for i:=1 to n do

begin

for j:=1 to n do

write(a[i,j],' ');

writeln;

end;

end.

Varianta 42:

a a 3 noduri elementul a[5,5]=5

var s:string[40];

i:integer;

begin

write(' s= '); read(s);

for i:=1 to length(s) do

if ( s[i]='a' ) or ( s[i]='e' ) or ( s[i]='i' ) or ( s[i]='o' ) or ( s[i]='u' )

then write(s[i],' ');

end.

Varianta 43:

a a

Nodul 4 - radacina / 5 noduri frunza (1, 3, 5, 7, 9)

var i,j,n:integer;

a:array[1..32,1..23]of integer;

begin

write(' n= '); read(n);

for i:=1 to n do

for j:=1 to n do

if i=j

then a[i,j]:=2

else if i<j

then a[i,j]:=1

else a[i,j]:=3;

for i:=1 to n do

begin

for j:=1 to n do

write(a[i,j],' ');

writeln;

end;

end.

Varianta 44:

a d fo

var a:array[1..23,1..23]of integer;

n,i,j,k:integer;

begin

write(' n= '); read(n);

for i:=1 to n do

begin

k:=i;

for j:=n downto 1 do

if k>1

then begin

a[i,j]:=k;

k:=k-1;

end

else a[i,j]:=1;

end;

for i:=1 to n do

begin

for j:=1 to n do

write(a[i,j],' ');

writeln;

end;

end.

Varianta 45:

a a a[2,1]=1

Decendentii radacinii: 1, 7 / Frunze 5, 6, 8, 9

var s:string[40];

i,j:integer;

begin

write(' s= '); read(s);

for i:=1 to length(s) do

begin

for j:=1 to length(s) do

if i<>j

then write(s[j]);

writeln;

end;

end.

Varianta 46:

c a 6 frunze 1 element

var s:string[100];

i:integer;

begin

write(' s= '); read(s);

for i:=1 to length(s) do

if ( s[i]='a' ) or ( s[i]='e' ) or ( s[i]='i' ) or ( s[i]='o' ) or ( s[i]='u' )

then s[i]:=chr( ord(s[i])+1 );

write(' s= ',s);

end.

Varianta 47:

c b acalaureat

f.a mod k =0 and f.b mod k =0

var n,m,m1,i,j:integer;

a,b:array[1..100,1..100]of integer;

begin

write(' n= '); read(n);

write(' m= '); read(m);

for i:=1 to m do

for j:=1 to n do

begin

write(' A[',i,',',j,']= ');

read(a[i,j]);

end;

for i:=1 to m do

for j:=1 to n do

if i mod 2=0

then b[i div 2,j]:=a[i,j];

m1:=m div 2 + m mod 2;

for i:=1 to m1 do

begin

for j:=1 to n do

write(b[i,j],' ');

writeln;

end;

end.

Varianta 48:

b a

sqrt(a.x*a.x+a.y*a.y)

var n,k,i,j:integer;

a,b:array[1..100,1..100]of integer;

begin

write(' n= '); read(n);

for i:=1 to n do

for j:=1 to n do

begin

k:=k+2;

a[i,j]:=k;

end;

for i:=1 to n do

begin

for j:=1 to n do

write(a[i,j],' ');

writeln;

end;

end.

Varianta 49:

d c (x.med1 + x.med2) / 2

var s,s1:string[20];

i:integer;

begin

write(' s= '); read(s);

s1:='';

for i:=1 to length(s) do

if ( s[i]='a' ) or ( s[i]='e' ) or ( s[i]='i' ) or ( s[i]='o' ) or ( s[i]='u' )

then s1:=s1+s[i];

write(' s1= ',s1);

end.

Varianta 50:

a d 6 noduri r

var s,s1:string[100];

i:integer;

function vocala(c:char):boolean;

begin

if ( c='a' ) or ( c='e' ) or ( c='i' ) or ( c='o' ) or ( c='u' )

then vocala:=true

else vocala:=false;

end;

begin

write(' s1= '); read(s1);

s:=s1;

i:=1;

while ( not vocala(s[i]) ) and (i<=length(s)) do

i:=i+1;

if i<length(s)+1 then delete(s,i,1);

i:=length(s);

while ( not vocala(s[i]) ) and (i>=1) do

i:=i-1;

if i>0 then delete(s,i,1);

write(' s= ',s);

end.

Varianta 51:

a d

Radacina 2 iar nodurile terminale 1, 4, 5, 8, 10

var s:string[30];

i:integer;

ok:boolean;

begin

write(' s= '); read(s);

ok:=true;

for i:=1 to length(s) do

if ( s[i]<>' ' ) and ( ( s[i]<'a' ) or ( s[i]>'z' ) ) and ( ( s[i]<'A' ) or ( s[i]>'Z' ) )

then ok:=false;

if ok

then write(' DA ')

else write(' NU ');

end.

Varianta 52:

a b

var s:string[100];

i:integer;

begin

write(' S= '); read(s);

if s[1]<>' '

then write(s[1]);

for i:=2 to length(s) do

if (s[i-1]=' ') and (s[i]<>' ')

then write(s[i]);

end.

Varianta 53:

c a

Tata=(3, 4, 4, 0, 2, 3, 6, 6). Descendentii sunt 6, 1, 7, 8 (insa numai primi doi sunt

descendenti directi)

var i, j, n, m, x, y, aux:integer;

a:array[1..20, 1..20]of integer;

begin

write(' m= '); read(m);

write(' n= '); read(n);

write(' x= '); read(x);

write(' y= '); read(y);

for i:=1 to m do

for j:=1 to n do

begin

write(' A[',i,',',j,']= ');

read(a[i,j]);

end;

for i:=1 to n do

begin

aux:=a[x,i];

a[x,i]:=a[y,i];

a[y,i]:=aux;

end;

for i:=1 to m do

begin

for j:=1 to n do

write(a[i,j],' ');

writeln;

end;

end.

Varianta 54:

d b k1=7; k2=4

var i, j, n, x:integer;

a:array[1..20, 1..20]of integer;

begin

write(' n= '); read(n);

write(' x= '); read(x);

for i:=1 to n do

for j:=1 to n do

if i mod 2=0

then a[i,j]:= x mod 10

else a[i,j]:=x div 10;

for i:=1 to n do

begin

for j:=1 to n do

write(a[i,j],' ');

writeln;

end;

end.

Varianta 55:

c a

var s,s1:string[100];

i:integer;

begin

write(' s= '); read(s);

s1:='';

for i:=1 to length(s) do

if (s[i]>='0') and (s[i]<='9')

then s1:=s1+s[i];

write(' s1= ',s1);

end.

Varianta 56:

c d (c>='a' and (c<='z')

var n,k,i,j:integer;

a:array[1..25,1..25]of integer;

begin

write(' n= '); read(n);

write(' k= '); read(k);

for i:=1 to n do

for j:=1 to n do

if j<=k

then a[i,j]:=1

else a[i,j]:=2;

for i:=1 to n do

begin

for j:=1 to n do

write(a[i,j]:3);

writeln;

end

end.

Varianta 57:

c a

(c='a') or (c='e') or (c='i') or (c='o') or (c='u')

var n,a,i,j:integer;

mat:array[1..25,1..25]of integer;

begin

write(' n= '); read(n);

write(' a= '); read(a);

for i:=1 to n do

for j:=1 to n do

if i<a

then mat[i,j]:=1

else if i=a

then mat[i,j]:=0

else mat[i,j]:=2;

for i:=1 to n do

begin

for j:=1 to n do

write(mat[i,j]:3);

writeln;

end

end.

Varianta 58:

b b i<>j

var s:string[50];

i,c:integer;

begin

write(' s= '); readln(s);

for i:=1 to length(s) do

if (s[i]>='a') and (s[i]<='z')

then c:=c+1;

write(' c= ',c);

end.

Varianta 59:

a c i=9

var s:string[50];

i,max:integer;

a:array[0..9] of integer;

begin

write(' s= '); readln(s);

for i:=1 to length(s) do

if (s[i]>='0') and (s[i]<='9')

then a[ord(s[i])-ord('0')]:=a[ord(s[i])-ord('0')]

max:=a[0];

for i:=1 to 9 do

if max<a[i]

then max:=a[i];

i:=0;

while a[i]<max do

i:=i+1;

write(i);

end.

Varianta 60:

d c

var s:string[50];

i,max:integer;

a:array[0..40] of integer;

begin

write(' s= '); readln(s);

for i:=1 to length(s) do

if (s[i]>='a') and (s[i]<='z')

then a[ord(s[i])-ord('a')]:=a[ord(s[i])-ord('a')]

max:=0;

for i:=0 to 40 do

if max<a[i]

then max:=a[i];

i:=0;

if max<>0

then begin

while a[i]<max do

i:=i+1;

write(chr( i+ord('a') ) );

end

else write(' NU ');

end.

Varianta 61:

d c f

var n,i,j:integer;

a:array[1..100,0..100]of integer;

begin

write(' n= '); read(n);

for j:=1 to n do

a[n,j]:=j;

for i:=n-1 downto 1 do

for j:=1 to i do

a[i,j]:=a[i+1,j-1]+a[i+1,j]+a[i+1,j+1];

for i:=1 to n do

begin

for j:=1 to n do

write(a[i,j]:3);

writeln;

end;

end.

Varianta 62:

a b e

var s:string[255];

i:integer;

a:array[0..255]of integer;

begin

write(' s= '); read(s);

for i:=1 to length(s) do

if (s[i]>='a') and (s[i]<='z') and (a[ord(s[i])]=0)

then begin

write(s[i],' ');

a[ord(s[i])]:=1;

end;

end.

Varianta 63:

b b

if length(s1)<length(s2)

then write(s1,' ',s2)

else write(s2,' ',s1);

var n,m,i,j,k:integer;

a:array[1..50,1..50] of integer;

begin

write(' n= '); read(n);

write(' m= '); read(m);

k:=1;

for j:=1 to m do

for i:=1 to n do

begin

a[i,j]:=k;

k:=k+1;

end;

for i:=1 to n do

begin

for j:=1 to m do

write(a[i,j]:4);

writeln;

end;

end.

Varianta 64:

d a

var s:string[100];

i,j,c:integer;

function vocala(c:char):boolean;

begin

vocala:=false;

if (c='a')or(c='A')or(c='e')or(c='E')or(c='i')or(c='I')or(c='o')or(c='O')or(c='u')or(c='U')

then vocala:=true;

end;

begin

write(' s= '); readln(s);

s:=' '+s; c:=0;

for i:=2 to length(s) do

if (s[i-1]=' ') and (s[i]<>' ')

then begin

j:=i;

while (s[j+1]<>' ') and (j<=n) do j:=j+1;

if vocala(s[i]) and vocala(s[j])

then c:=c+1;

end;

write(c);

end.

Varianta 65:

c d f

var n,m,i,j,k:integer;

a:array[1..50,1..50] of integer;

begin

write(' n= '); read(n);

write(' m= '); read(m);

k:=1;

for i:=1 to n do

if i mod 2 =1

then for j:=1 to m do

begin

a[i,j]:=k;

k:=k+1;

end

else for j:=m downto 1 do

begin

a[i,j]:=k;

k:=k+1;

end;

for i:=1 to n do

begin

for j:=1 to m do

write(a[i,j]:4);

writeln;

end;

end.

Varianta 66:

c b

var s:string[50];

k:integer;

begin

write(' s= '); read(s);

for k:=1 to length(s) do

writeln(copy(s,1,k));

end.

Varianta 67:

a c 2 descendenti

var s:string[50];

k:integer;

begin

write(' s= '); read(s);

for k:=length(s) downto 1 do

writeln(copy(s,k,length(s)-k+1));

end.

Varianta 68:

d a T=(0, 1, 1, 2, 2, 5, 5) length()

var n,m,i,j:integer; p:longint;

a:array[1..50,1..50] of integer;

begin

write(' m= '); read(m);

write(' n= '); read(n);

for i:=1 to m do

for j:=1 to n do

begin

write(' A[',i,',',j,']= ');

read(a[i,j]);

end;

p:=1;

for i:=1 to m do

for j:=1 to n do

if (i mod 2 =0) and (j mod 2= 1) and (a[i,j]>0)

then p:=p*a[i,j];

write(' p= ',p);

end.

Varianta 69:

b c T=(0, 1, 1, 3, 3, 4, 4) t:=copy(s,1,n);

var n,i,j:integer; ok:boolean;

a:array[1..50,1..50] of integer;

begin

write(' n= '); read(n);

for i:=1 to n do

for j:=1 to n do

begin

write(' A[',i,',',j,']= ');

read(a[i,j]);

end;

ok:=true;

for i:=2 to n do

for j:=1 to i-1 do

if (a[i,j]>0)

then ok:=false;

if ok

then write(' Este triunghiulara superior')

else write(' Nu este trunghiulara superior');

end.

Varianta 70:

a d T=(2, 0, 2, 5, 2)

write(s[length(s)]);

var n,m,i,j,x:integer;

a:array[1..50,1..50] of integer;

begin

write(' m= '); read(m);

write(' n= '); read(n);

write(' x= '); read(x);

for i:=1 to m do

for j:=1 to n do

begin

write(' A[',i,',',j,']= ');

read(a[i,j]);

end;

for i:=x+1 to m do

for j:=1 to n do

a[i-1,j]:=a[i,j];

m:=m-1;

for i:=1 to m do

begin

for j:=1 to n do

write(a[i,j]:6);

writeln;

end;

end.

Varianta 71:

c d

s1:=s1+a[i,i];

s2:=s2+a[i,n-i+1];

readln(e1.nume); readln(e1.nota);

readln(e2.nume); readln(e2.nota);

if e1.nota>=e2.nota

then write(e1.nota)

else write(e2.nota);

var n,i,j,k:integer;

a:array[1..100,1..100]of integer;

begin

write(' n= '); read(n);

k:=0;

for j:=1 to n do

for i:=1 to n do

begin

k:=k+1;

a[i,j]:=k;

end;

for i:=1 to n do

begin

for j:=1 to n do

write(a[i,j]:4);

writeln;

end;

end.

Varianta 72:

c a 3 comp. conexe 1 arc

var n,i,j,k:integer;

a:array[1..100,1..100]of integer;

begin

write(' n= '); read(n);

k:=0;

for i:=1 to n do

for j:=1 to n-i+1 do

begin

k:=k+1;

a[i,j]:=k;

end;

k:=0;

for j:=n downto 2 do

for i:=n downto n-j+1 do

begin

k:=k+1;

a[i,j]:=k;

end;

for i:=1 to n do

begin

for j:=1 to n do

write(a[i,j]:3);

writeln;

end;

end.

Varianta 73:

b d 2 arce; C=(1,2,3,4,1)

j,aux:integer;

for j:=1 to n do

begin

aux:=a[p,j];

a[p,j]:=a[q,j];

a[q,j]:=aux;

end;

var s:string;

nc,nv,i:integer;

begin

write(' S= '); readln(s);

s:=' '+s;

nc:=0; nv:=0;

for i:=2 to length(s) do

if (s[i-1]=' ') and (s[i]<>' ')

then begin

nc:=nc+1;

if (s[i]='a') or (s[i]='e') or (s[i]='i') or (s[i]='o') or (s[i]='u')

then nv:=nv+1;

end;

write(nc,' ',nv);

end.

Varianta 74:

a c

a) 4, 6, 9 b) 5 noduri (1, 3, 4, 5, 7)

a) 2 muchii b) o muchie

var n,i,j:integer;

a:array[1..100,1..100]of integer;

begin

write(' n= '); read(n);

for i:=1 to n do

for j:=1 to n do

if i mod 2=0

then a[i,j]:=n-j+1

else a[i,j]:=j;

for i:=1 to n do

begin

for j:=1 to n do

write(a[i,j]:4);

writeln;

end;

end.

Varianta 75:

d d

ADD 5; ELIM; 2 arce ( arcul (2, 3) si (4, 1) )

var n,m,i,j:integer;

a:array[1..100,1..100]of integer;

begin

write(' m= '); read(m);

write(' n= '); read(n);

for i:=1 to m do

for j:=1 to n do

if (i-1) div 2 mod 2=0

then a[i,j]:=0

else a[i,j]:=1;

for i:=1 to m do

begin

for j:=1 to n do

write(a[i,j]:3);

writeln;

end;

end.

Varianta 76:

b a T=(5, 3, 6, 6, 7, 0, 6, 3)

var s:string[20];

i,j:integer;

begin

write(' S= '); readln(s);

for i:=0 to length(s) div 2 do

begin

for j:=i+1 to length(s)-i do

write(s[j]);

writeln;

end;

end.

Varianta 77:

a c

var s:string[51];

i:integer;

begin

write(' S= '); readln(s);

s:=' '+s;

for i:=2 to length(s) do

if (s[i-1]=' ') and (s[i]<>' ')

then s[i]:=chr( ord(s[i])-ord('a')+ord('A') );

delete(s,1,1);

write(' s= ',s);

end.

Varianta 78:

c b

var t,x:string[100];

c:string[15]; p:integer;

function gasire(s,c:string; ind:integer):integer;

var i,j:integer;

ok:boolean;

begin

for i:=ind to length(s) do

if (s[i]=c[1])

then begin

ok:=true;

j:=1;

while (j<length(c)) and (ok) do

begin

if c[j]<>s[i+j-1]

then ok:=false;

j:=j+1;

end;

if ok

then begin gasire:=i; exit; end;

end;

gasire:=0;

end;

begin

write(' textul: '); readln(t);

write(' cuvantul: '); readln(c);

p:=1;

repeat

p:=gasire(t,c,p);

if p<>0

then begin

while (t[p]<>' ') and ( p<length(t) ) do

p:=p+1;

t:=copy(t,1,p-1)+'?'+copy(t,p,length(t));

end;

until p=0;

write(' t= ',t);

end.

Varianta 79:

a a 5 muchii

T=(1, 0, 6, 9, 2, 5, 4, 3, 2, 6, 4, 6, 2)

var s:string;

i:integer;

function vocala(c:char):boolean;

begin

if (c='A') or (c='E') or (c='I') or (c='O') or

(c='U')

then vocala:=true

else vocala:=false;

end;

begin

write(' s= '); readln(s);

i:=1;

while i<length(s) do

begin

if vocala(upcase(s[i]))

then s:=copy(s,1,i)+'*'+copy(s,i+1,length(s));

i:=i+1;

end;

write(s);

end.

Varianta 80:

d c

var s:string;

i,j:integer;

aux:char;

begin

write(' s= '); readln(s);

for i:=1 to length(s) div 2 do

begin

j:=length(s) div 2 + length(s) mod 2 + i;

aux:=s[i];

s[i]:=s[j];

s[j]:=aux;

end;

write(' s= ',s);

end.

Varianta 81:

c a

a:=a+b;

b:=a-b;

a:=a-b;

if (length(cuv) mod 2=0)

then write(cuv[length(cuv) div 2],cuv[length(cuv) div 2+1]

else write(cuv[length(cuv) div 2 +1]);

var n,m,i,j,imin,imax,jmin,jmax,aux:integer;

a:array[1..100,1..100]of integer;

begin

write(' n= '); read(n);

write(' m= '); read(m);

for i:=1 to n do

for j:=1 to m do

begin

write(' A[',i,',',j,']= ');

read(a[i,j]);

end;

imin:=1; jmin:=1;

imax:=1; jmax:=1;

for i:=1 to n do

for j:=1 to m do

begin

if a[i,j]<a[imin,jmin]

then begin

imin:=i;

jmin:=j;

end;

if a[i,j]>a[imax,jmax]

then begin

imax:=i;

jmax:=j;

end;

end;

aux:=a[imin,jmin];

a[imin,jmin]:=a[imax,jmax];

a[imax,jmax]:=aux;

for i:=1 to n do

begin

for j:=1 to m do

write(a[i,j]:4);

writeln;

end;

end.

Varianta 82:

c c tarta

noduri cu grad par: 2; noduri cu grad impar: 2

var n,i,j,imin,imax,aux:integer;

a:array[1..100,1..100]of integer;

begin

write(' n= '); read(n);

for i:=1 to n do

for j:=1 to n do

begin

write(' A[',i,',',j,']= ');

read(a[i,j]);

end;

imin:=1;

imax:=1;

for i:=1 to n do

begin

if a[i,i]<a[imin,imin]

then imin:=i;

if a[i,i]>a[imax,imax]

then imax:=i;

end;

aux:=a[imin,imin];

a[imin,imin]:=a[imax,imax];

a[imax,imax]:=aux;

for i:=1 to n do

begin

for j:=1 to n do

write(a[i,j]:4);

writeln;

end;

end.

Varianta 83:

a

for i:=1 to length(cuv) do

if (cuv[i]='a') or (cuv[i]='e') or (cuv[i]='i') or (cuv[i]='o') or (cuv[i]='u')

then write(cuv[i]);

var n,i,j,imin,imax,aux:integer;

a:array[1..100,1..100]of integer;

begin

write(' n= '); read(n);

for i:=1 to n do

for j:=1 to n do

begin

write(' A[',i,',',j,']= ');

read(a[i,j]);

end;

imin:=1;

imax:=1;

for i:=1 to n do

begin

if a[i,n+1-i]<a[imin,n+1-imin]

then imin:=i;

if a[i,n+1-i]>a[imax,n+1-imax]

then imax:=i;

end;

aux:=a[imin,n+1-imin];

a[imin,n+1-imin]:=a[imax,n+1-imax];

a[imax,n+1-imax]:=aux;

for i:=1 to n do

begin

for j:=1 to n do

write(a[i,j]:4);

writeln;

end;

end.

Varianta 84:

a a write(chr(ord(c)+1);

write(el.nume,' ',el.prenume,' ', el.mediabac);

var n,i,j:integer; p:longint; ok:boolean;

a:array[1..100,1..100]of integer;

begin

write(' n= '); read(n);

for i:=1 to n do

for j:=1 to n do

begin

write(' A[',i,',',j,']= ');

read(a[i,j]);

end;

p:=1;

ok:=false;

for i:=1 to n do

if a[i,i] mod 2=0

then begin

ok:=true;

p:=p*a[i,i];

end;

if ok

then write(' p= ',p)

else write(' IMPOSIBIL ');

end.

Varianta 85:

a b

readln(p.nume);

readln(p.prenume);

readln(p.salariu);

write(a[1,1]*a[2,2]*a[3,3]*a[4,4]);

var n,i,j:integer; p:longint; ok:boolean;

a,b,c:array[1..10,1..10]of integer;

begin

write(' n= '); read(n);

for i:=1 to n do

for j:=1 to n do

begin

write(' A[',i,',',j,']= ');

read(a[i,j]);

end;

for i:=1 to n do

for j:=1 to n do

begin

write(' B[',i,',',j,']= ');

read(b[i,j]);

end;

for i:=1 to n do

for j:=1 to n do

if i<j

then c[i,j]:=a[i,j]

else if i>j

then c[i,j]:=b[i,j]

else if a[i,j]<b[i,j]

then c[i,j]:=a[i,j]

else c[i,j]:=b[i,j];

for i:=1 to n do

begin

for j:=1 to n do

write(c[i,j]:4);

writeln;

end;

end.

Varianta 86:

d a

var n,i,j,i1,i2:integer;

a:array[1..20,1..20]of integer;

begin

write(' n= '); read(n);

i1:=1;

for i:=1 to 2*n do

if i mod 2 =1

then for j:=1 to 2*n do

begin

a[i,j]:=i1;

i1:=i1+2;

end

else begin

i2:=i1-4*n+1;

for j:=2*n downto 1 do

begin

a[i,j]:=i2;

i2:=i2+2;

end;

end;

for i:=1 to 2*n do

begin

for j:=1 to 2*n do

write(a[i,j]:4);

writeln;

end;

end.

Varianta 87:

d b

var a:array[1..20,1..20] of integer;

i,j,n,s,nr:integer;

begin

write(' n= '); read(n);

for i:=1 to n do

for j:=1 to n do

begin

write(' A[',i,',',j,']= ');

read(a[i,j]);

end;

s:=0; nr:=0;

for i:=2 to n do

for j:=1 to i-1 do

if a[i,j]>0

then begin

s:=s+a[i,j];

nr:=nr+1;

end;

write(' MA= ',(s/nr):5:2);

end.

Varianta 88:

a b

var a:array[1..20,1..20] of integer;

i,j,n,s,nr:integer;

begin

write(' n= '); read(n);

for i:=1 to n do

for j:=1 to n do

begin

write(' A[',i,',',j,']= ');

read(a[i,j]);

end;

s:=0; nr:=0;

for i:=1 to n-1 do

for j:=i+1 to n do

if a[i,j]>0

then begin

s:=s+a[i,j];

nr:=nr+1;

end;

write(' MA= ',(s/nr):5:2);

end.

Varianta 89:

d a

var T:array[1..6,1..6] of integer;

i,j,n,a,c,b:integer;

begin

write(' n= '); read(n);

a:=1; b:=0;

for i:=1 to n do

if i mod 2=1

then for j:=1 to n do

begin

T[i,j]:=b;

c:=a+b;

a:=b;

b:=c;

end

else for j:=n downto 1 do

begin

T[i,j]:=b;

c:=a+b;

a:=b;

b:=c;

end;

for i:=1 to n do

begin

for j:=1 to n do

write(T[i,j]:4);

writeln;

end;

end.

Varianta 90:

a b

var a:array[1..20,1..20] of integer;

i,j,n,s,nr,s2,nr2:integer;

m1,m2:real;

begin

write(' n= '); read(n);

for i:=1 to n do

for j:=1 to n do

begin

write(' A[',i,',',j,']= ');

read(a[i,j]);

end;

s:=0; nr:=0;

for i:=1 to n-1 do

for j:=i+1 to n do

if a[i,j]>0

then begin

s:=s+a[i,j];

nr:=nr+1;

end;

m1:= s / nr;

s2:=0; nr2:=0;

for i:=2 to n do

for j:=1 to i-1 do

if a[i,j]>0

then begin

s2:=s2+a[i,j];

nr2:=nr2+1;

end;

m2:= s2 / nr2;

write(' M1-M2= ',m1-m2:5:2);

end.

Varianta 91:

b a iarba

var a:array[1..50,1..50] of integer;

i, j, n, m, v0, ind, max:integer;

begin

write(' n= '); read(n);

write(' m= '); read(m);

for i:=1 to n do

for j:=1 to m do

begin

write(' A[',i,',',j,']= ');

read(a[i,j]);

end;

ind:=0; max:=0;

for i:=1 to n do

begin

v0:=0;

for j:=1 to m do

if a[i,j]>0

then v0:=v0+1;

if v0>max

then begin

max:=v0;

ind:=i;

end;

end;

write(' Ind= ',ind);

end.

Varianta 92:

b b

( v.origine.x = v.extremitate.x ) and ( v.origine.y = v.extremitate.y )

var a:array[1..50,1..50] of integer;

i, j, n, m, imin, jmin, max:integer;

begin

write(' m= '); read(m);

write(' n= '); read(n);

for i:=1 to m do

for j:=1 to n do

begin

write(' A[',i,',',j,']= ');

read(a[i,j]);

end;

imin:=1; jmin:=1;

for i:=1 to m do

for j:=1 to n do

if a[i,j]<a[imin,jmin]

then begin

imin:=i;

jmin:=j;

end;

for i:=1 to m do

for j:=jmin+1 to n do

a[i,j-1]:=a[i,j];

n:=n-1;

for j:=1 to n do

for i:=imin+1 to m do

a[i-1,j]:=a[i,j];

m:=m-1;

for i:=1 to m do

begin

for j:=1 to n do

write(a[i,j],' ');

writeln;

end;

end.

Varianta 93:

d b

var sa1,sa2,s1,s2:string[200];

i:integer;

function sablon(x:string):string;

var s:string;

begin

s:='';

for i:=1 to length(x) do

if (x[i]='a') or (x[i]='e') or (x[i]='i') or

(x[i]='o') or (x[i]='u')

then s:=s+'*'

else s:=s+'#';

sablon:=s;

end;

begin

write(' s1= '); readln(s1);

write(' s2= '); readln(s2);

sa1:=sablon(s1);

sa2:=sablon(s2);

for i:=1 to length(sa1) do

if sa1[i]=sa2[i]

then write(sa1[i])

else write('?');

end.

Varianta 94:

b a

var s:string[20];

i,j:integer;

begin

write(' s= '); readln(s);

i:=pos(' ',s);j:=i;

while s[i]=' ' do i:=i+1;

s:=copy(s,i,length(s))+' '+copy(s,1,j-1);

write(' s= ',s);

end.

Varianta 95:

b d

lungime:5 arcele: (1, 2); (2, 4); (4, 3); (3, 2); (2 ,5)

var s:string[20];

i,j:integer;

begin

write(' s= '); readln(s);

i:=pos(' ',s);j:=i;

while s[i]=' ' do i:=i+1;

s:=copy(s,i,1)+'. '+copy(s,1,j-1);

write(' s= ',s);

end.

Varianta 96:

d a

var n,p:string[20];

s:string[40];

begin

write(' nume= '); readln(n);

write(' prenume= '); readln(p);

s:=p+' '+n;

write(' s= ',s);

end.

Varianta 97:

c a TITA

var a:array[1..50,1..50]of integer;

n,m,i,j,aux:integer;

begin

write(' n= '); read(n);

write(' m= '); read(m);

for i:=1 to n do

for j:=1 to m do

begin

write(' A[',i,',',j,']= ');

read(a[i,j]);

end;

for j:=1 to m do

for i:=1 to n div 2 do

begin

aux:=a[i,j];

a[i,j]:=a[n-i+1,j];

a[n-i+1,j]:=aux;

end;

for i:=1 to n do

begin

for j:=1 to m do

write(a[i,j],' ');

writeln;

end;

end.

Varianta 98:

b a

type COLET=record

pret, greutate:real;

nume_oras:string[30];

end;

var x:COLET;

readln(x.pret); readln(x.greutate); readln(x.nume_oras);

var a:array[1..50,1..50]of integer;

n,i,j,k:integer;

begin

write(' n= '); read(n);

k:=0;

for i:=1 to n do

for j:=1 to n do

begin

a[i,j]:=k;

k:=k+2;

end;

for i:=1 to n do

begin

for j:=1 to n do

write(a[i,j],' ');

writeln;

end;

end.

Varianta 99:

b a

var a:array[1..50,1..50]of integer;

n,i,j:integer;

begin

write(' n= '); read(n);

for i:=1 to n do

for j:=1 to n do

if i>j

then a[i,j]:=i

else a[i,j]:=j;

for i:=1 to n do

begin

for j:=1 to n do

write(a[i,j],' ');

writeln;

end;

end.

Varianta 100:

d a

var a:array[1..102,1..102]of longint;

n,m,i,j,aux:integer;

begin

write(' n= '); read(n);

for i:=2 to n+1 do

for j:=2 to n+1 do

begin

write(' A[',i-1,',',j-1,']= ');

read(a[i,j]);

end;

for i:=1 to n+2 do

begin

a[1,i]:=maxlongint;;

a[n+2,i]:=maxlongint;;

a[i,1]:=maxlongint;;

a[i,n+2]:=maxlongint;;

end;

for i:=2 to n+1 do

for j:=2 to n+1 do

if (a[i,j]<a[i-1,j]) and (a[i,j]<a[i+1,j]) and

(a[i,j]<a[i,j-1]) and (a[i,j]<a[i,j+1])

then write(a[i,j],' ');

end.

Varianta 1:

b

var f:text;

n,nr:integer;

begin

write(' N= '); read(n);

assign(f,'bac.txt'); reset(f);

while not eof(f) do

begin

read(f,nr);

if nr mod n =0

then write(nr,' ');

end;

close(f);

end.

type sir=array[1..100]of integer;

var a:sir;

n,i:integer;

gasit:boolean;

function sub(v:sir;n,a:integer):integer;

var e,i:integer;

begin

e:=0;

for i:=1 to n do

if v[i]=a

then e:=e+1;

sub:=e;

end;

begin

write(' N= '); read(n);

for i:=1 to n do

begin

write(' A[',i,']= ');

read(a[i]);

end;

gasit:=false;

i:=1;

while (not gasit) and (i<n) do

begin

if sub(a,n,a[i])>1

then gasit:=true;

i:=i+1;

end;

if gasit

then write(' NU')

else write(' DA');

end.

Varianta 2:

d

var a:array[1..100]of integer;

f:text; sortat:boolean;

n, nr, i, aux:integer;

begin

assign(f,'nr.txt'); reset(f);

n:=0;

while not eof(f) do

begin

read(f,nr);

if nr >0

then begin

n:=n+1;

a[n]:=nr;

end;

end;

close(f);

if n=0 then write(' NU EXISTA')

else begin

repeat

sortat:=true;

for i:=1 to n-1 do

if a[i]>a[i+1]

then begin

aux:=a[i];

a[i]:=a[i+1];

a[i+1]:=aux;

sortat:=false;

end;

until sortat;

for i:=1 to n do

write(a[i],' ');

end;

end.

var n,n1:integer;

function f(a:integer):integer;

var i,s,d:integer;

begin

d:=2; s:=0;

while a>1 do

begin

while a mod d=0 do

begin

a:=a div d;

s:=s+1;

end;

d:=d+1;

end;

f:=s;

end;

begin

write(' n= '); read(n);

if n<10

then n1:=2

else n1:=n mod 10 *10 + n div 10;

if (f(n)=1) and (f(n1)=1)

then write(' DA ')

else write(' NU ');

end.

Varianta 3:

a xxxyyy

var a:array[1..100]of integer;

f:text; sortat:boolean;

n, nr, i, aux:integer;

begin

assign(f,'nr.txt'); reset(f);

n:=0;

while not eof(f) do

begin

read(f,nr);

if (nr > 99) or (nr < -99)

then begin

n:=n+1;

a[n]:=nr;

end;

end;

close(f);

repeat

sortat:=true;

for i:=1 to n-1 do

if a[i]>a[i+1]

then begin

aux:=a[i];

a[i]:=a[i+1];

a[i+1]:=aux;

sortat:=false;

end;

until sortat;

if n=0

then write(' NU EXISTA! ')

else for i:=1 to n do

write(a[i],' ');

end.

var n ,c, i, na:longint;

function cif(a:longint; b:byte):byte;

var na:byte;

begin

na:=0;

while a>0 do

begin

if a mod 10 = b

then na:=na+1;

a:=a div 10;

end;

cif:=na;

end;

begin

write(' n= '); read(n);

c:=9;

while c>0 do

begin

na:=cif(n,c);

for i:=1 to na do write(c);

c:=c-2;

end;

end.

Varianta 4:

c

var a:array[1..100]of integer;

f:text; sortat:boolean;

n, nr, i, aux:integer;

begin

assign(f,'nr.txt'); reset(f);

n:=0;

while not eof(f) do

begin

read(f,nr);

if (nr < 100) and (nr > -100)

then begin

n:=n+1;

a[n]:=nr;

end;

end;

close(f);

repeat

sortat:=true;

for i:=1 to n-1 do

if a[i]<a[i+1]

then begin

aux:=a[i];

a[i]:=a[i+1];

a[i+1]:=aux;

sortat:=false;

end;

until sortat;

if n=0

then write(' NU EXISTA! ')

else for i:=1 to n do

write(a[i],' ');

end.

var n ,c, i, na:longint;

function cif(a:longint; b:byte):byte;

var na:byte;

begin

na:=0;

while a>0 do

begin

if a mod 10 = b

then na:=na+1;

a:=a div 10;

end;

cif:=na;

end;

begin

write(' n= '); read(n);

c:=1;

while c<10 do

begin

na:=cif(n,c);

for i:=1 to na do write(c);

c:=c+2;

end;

end.

Varianta 5:

d

var n:longint;

f:text;

begin

assign(f,'nr.txt'); rewrite(f);

write(' n= '); read(n);

while n>0 do

begin

write(f,n,' ');

n:=n div 10;

end;

close(f);

end.

var n,i:integer; gasit:boolean;

a:array[1..100]of longint;

function f(a:longint):longint;

var d:longint;

begin

d:=2;

while a mod d <>0 do d:=d+1;

f:=d

end;

begin

write(' n= '); read(n);

for i:=1 to n do

begin

write(' A[',i,']= ');

read(a[i]);

end;

gasit:=false;

for i:=1 to n do

if f(a[i]) = a[i]

then begin

gasit:=true;

write(a[i],' ');

end;

if not gasit

then write(' NU EXISTA! ');

end.

Varianta 6:

a

type sir=array[0..100]of integer;

var n,i,i1,i2:integer;

a:sir;

f:text;

procedure s1(var a,b:integer);

begin

a:=a+b;

b:=a-b;

a:=a-b;

end;

function s2(a:sir; p:integer;q:integer):integer;

var i:integer;

begin

if p<q then begin

i:=p;

while (i<=q) and (a[i] mod 5 <> 0) do

i:=i+1;

if i = q+1

then s2:=-1

else s2:=i;

end

else begin

i:=p;

while (i>=q) and (a[i] mod 5 <> 0) do

i:=i-1;

if i = q-1

then s2:=-1

else s2:=i;

end

end;

begin

assign(f,'bac.txt'); rewrite(f);

write(' n= '); read(n);

for i:=1 to n do

begin

write(' A[',i,']= ');

read(a[i]);

end;

i1:=s2(a,1,n);

i2:=s2(a,n,1);

s1(a[i1],a[i2]);

writeln(i1,' ',i2);

for i:=1 to n do

write(f,a[i],' ');

close(f);

end.

Varianta 7:

d

var a:array[1..300] of integer;

n,i,aux:integer;

begin

write(' n= '); read(n);

for i:=1 to 3*n do

begin

write(' A[',i,']= ');

read(a[i]);

end;

for i:=1 to n do

begin

aux:=a[i];

a[i]:=a[2*n+i];

a[2*n+i]:=aux;

end;

for i:=1 to 3*n do

write(a[i],' ');

end.

var s,n:longint;

g:text;

function f(n:longint):longint;

var x,y:longint;

begin

x:=1;

while x<n do

begin

if x<5

then x:=x+1

else x:=2*x;

end;

if n>5

then f:=x div 2

else f:=x;

end;

begin

assign(g,'numere.txt'); rewrite(g);

write(' s= '); read(s);

while s>1 do

begin

n:=f(s);

write(g,n,' ');

s:=s-n;

end;

close(g);

end.

Varianta 8:

c 4 numere (105, 123, 321, 501)

var f:text;

i,j,n:integer;

begin

assign(f,'bac.txt'); rewrite(f);

write(' n= '); read(n);

for i:=1 to n do

begin

for j:=0 to n-i do

write(f,2*j,' ');

writeln(f);

end;

close(f);

end.

var n:longint;

c0,s:integer;

function p1(n:longint):integer;

var s:integer;

begin

s:=0;

while n>0 do

begin

s:=s+n mod 10;

n:=n div 10;

end;

p1:=s;

end;

function p2(n:longint):longint;

begin

p2:=n div 10;

end;

begin

write(' n= '); read(n);

s:=p1(n); n:=p2(n);

while n>0 do

begin

if s=p1(n)

then c0:=c0+1;

s:=p1(n);

n:=p2(n);

end;

write(' c0= ',c0);

end.

Varianta 9:

a

type sir=array[0..100]of integer;

var n,i,j:integer;

a:sir;

f:text;

procedure s1(a:sir; var p, q:integer);

var i:integer;

begin

i:=p;

while (i<=q) and (a[i] mod 2 <> 0) do i:=i+1;

if i = q+1

then p:=-1

else p:=i;

i:=q;

while (i>=p) and (a[i] mod 2 = 0) do i:=i-1;

if i = q-1

then q:=-1

else q:=i;

end;

procedure s2(var a,b:integer);

begin

a:=a+b;

b:=a-b;

a:=a-b;

end;

begin

assign(f,'bac.txt'); rewrite(f);

write(' n= '); read(n);

for i:=1 to n do

begin

write(' A[',i,']= ');

read(a[i]);

end;

i:=1; j:=n;

s1(a,i,j);

while (i<>-1) and (j<>-1) and (i<j) do

begin

s2(a[i],a[j]);

s1(a,i,j);

end;

for i:=1 to n do

write(f,a[i],' ');

close(f);

end.

Varianta 10:

b

var a:array[1..100] of integer;

n,i,j,s:integer;

begin

write(' n= '); read(n);

for i:=1 to n do

begin

write(' A[',i,']= ');

read(a[i]);

end;

for i:=1 to n do

begin

s:=0;

for j:=1 to n-i+1 do

s:=s+a[j];

writeln(s);

end;

end.

4.a) var i,n,nr,p2:longint;

f:text;

begin

assign(f,'bac.txt'); rewrite(f);

write(' n= '); read(n);

p2:=1;

for i:=1 to n do

begin

write(' nr= '); read(nr);

while p2<nr do p2:=p2*2;

write(f,p2,' ');

end;

close(f);

end.

4.b) Īn variabila p2 retin puterile lui 2. Initial este 20 adica 1. Citesc, pe rānd, cele n

numere. Daca numarul citit este mai mare decāt p2 aflu care este puterea lui 2

astfel īncāt sa fie respectate conditiile, apoi afisez valoarea determinata.

Programul este eficient deoarece nu foloseste structuri de date pentru a retine

toate elementele sirului si nu determina de fiecare data 2x ci numai adauga la

ultima putere, (daca este necesar). Īn concluzie programul consuma putina

memorie si este rapid.

Varianta 11:

b

type sir=array[1..100]of integer;

var a,b:sir;

n,i,m:integer;

procedure P(a:sir; k:integer; var max:integer);

var i:integer;

begin

max:=a[1];

for i:=1 to k do

if max<a[i]

then max:=a[i];

end;

begin

write(' n= '); read(n);

for i:=1 to n do

begin

write(' A[',i,']= ');

read(a[i]);

end;

for i:=1 to n do

begin

P(a,i,m);

b[i]:=m;

end;

for i:=1 to n do

write(b[i],' ');

end.

var a:array[1..100]of longint;

i,n,np:longint;

function prim(x:longint):boolean;

var d:longint;

begin

d:=2;

while (x mod d <>0)and (x>1) do d:=d+1;

if d=x

then prim:=true

else prim:=false;

end;

begin

np:=0;

write(' N= '); read(n);

for i:=1 to n do

begin

write(' A[',i,']= ');

read(a[i]);

end;

for i:=1 to n do

if prim(a[i])

then np:=np+1;

write(' np= ', np);

end.

Varianta 12:

c

Rezolvari Subiectul III

3.a) Citesc primele m numere īntr-un sir apoi urmatoarele n numere pe rānd. Dupa

citirea unui nou numar continu parcurgerea sirului p穗a ajung la o valoare care

nu este mai mica decat cea citita. Fiecare valoare din sir peste care sar este

numarata. Daca ultima valoare parcursa īn sir este diferita de cea citita atunci am

mai descoperit o valoare care apare o singura data.

Programul este eficient deoarece nu retine toate elementele deci consuma

putnna memorie si percurge sirul o singura data deci este rapid.

3.b) var m,n,x,i,j:integer;

a:array[1..101]of longint;

nr:longint;

begin

write(' m= '); read(m);

write(' n= '); read(n);

for i:=1 to m do

begin

write(' a[',i,']= ');

read(a[i]);

end;

x:=0; j:=1;

for i:=1 to n do

begin

write(' nr= ');

read(nr);

while (a[j]<nr) and (j<=m) do begin

x:=x+1;

j:=j+1;

end;

if a[j]<>nr then x:=x+1

else j:=j+1;

end;

write(' Numere distincte: ',x);

end.

var n,i,cd:longint;

function nr(n:longint; c:byte): byte;

var x:byte;

begin

x:=0;

while n >0 do

begin

if n mod 10 = c

then x:=x+1;

n:=n div 10;

end;

nr:=x;

end;

begin

write(' n= '); read(n);

Rezolvari Subiectul III

cd:=0;

for i:=0 to 9 do

if nr(n,i)>0

then cd:=cd+1;

write(' cifre dist: ',cd);

end.

Varianta 13:

d

var i,j,n:integer;

begin

write(' n= '); read(n);

i:=1;

while n>0 do

begin

j:=i;

while (j>0) and (n>0) do

begin

write(j,' ');

j:=j-1;

n:=n-1;

end;

i:=i+1;

end;

end.

var f,g:text;

nr:longint;

procedure P(var n:longint; c:byte);

var i:integer;

s,s2:string[10];

begin

str(n,s); str(c,s2);

for i:=1 to length(s) do

if s[i]=s2

then delete(s,i,1);

val(s,n,i);

end;

begin

assign(f,'bac.in'); reset(f);

assign(g,'bac.out'); rewrite(g);

while not eof(f) do

begin

read(f,nr);

P(nr,1);

P(nr,3);

P(nr,5);

Rezolvari Subiectul III

P(nr,7);

P(nr,9);

if nr>0 then write(g,nr,' ');

end;

close(f);

close(g);

end.

Varianta 14:

b

var f:text;

nr,c:longint;

begin

assign(f,'bac.txt'); reset(f);

c:=0;

while not eof(f) do

begin

read(f,nr);

write(nr,' ');

c:=c+1;

if c mod 5 =0

then writeln;

end;

close(f);

end.

var i,ii:integer;

function prim(n:integer):byte;

var d:integer;

begin

d:=2;

while n mod d<>0 do d:=d+1;

if n=d then prim:=1

else prim:=0;

end;

begin

for i:=11 to 97 do

begin

ii:=i mod 10 * 10 + i div 10;

if (prim(i)=1) and (prim(ii)=1)

then write(i,' ');

end;

end.

Rezolvari Subiectul III

Varianta 15:

b

var n,n5:longint;

begin

n5:=0;

write(' n= '); read(n);

while n<>0 do

begin

while n>0 do

begin

if n mod 10 =5 then n5:=n5+1;

n:=n div 10;

end;

write(' n= '); read(n);

end;

write(' n5= ',n5);

end.

4.a. Consieer initial ultimul nr impar -1. Citesc pe rānd cate un numar si verific

daca este impar. Īn caz afirmativ īl retin. La final daca valoarea din ni este

diferita de -1 絜seamna ca fisierul continea cel putin un numar impar si afisez

valoarea variablei altfel textul cerut.

Algritmul este eficient fiindca prelucreaza o singura data numerele din fisier

si nu foloseste structuri de date (siruri) pentru a rtine elementele

4.b. var f:text;

nr,ni:longint;

begin

ni:=-1;

assign(f,'bac.in'); reset(f);

while not eof(f) do

begin

read(f,nr);

if nr mod 2 <> 0

then ni:=nr;

end;

if ni=-1

then write(' Nu exista numere impare ')

else write(ni);

end.

Varianta 16:

d

var a:array[1..10] of integer;

i,m13:integer;

begin

Rezolvari Subiectul III

write(' Numerele: ');

for i:=1 to 10 do read(a[i]);

m13:=0;

for i:=1 to 10 do

if a[i] mod 13=0

then m13:=m13+1;

write(m13,' ');

for i:=1 to 10 do

if a[i] mod 13 = 0

then write(i,' ');

end.

var f:text;

n:longint;

function cifrak(n:longint; k:byte):byte;

var nc:byte;

begin

nc:=0;

while n>0 do

begin

if n mod 10 = k

then nc:=nc+1;

n:=n div 10;

end;

cifrak:=nc;

end;

begin

assign(f,'numere.txt'); reset(f);

while not eof(f) do

begin

read(f,n);

if cifrak(n,0)=3

then write(n,' ');

end;

close(f);

end.

Varianta 17:

c

function interval(v:sir; d:byte):byte;

var i,ne:byte;

begin

if v[1]>v[n]

then begin

ne:=v[1];

v[1]:=v[n];

Rezolvari Subiectul III

v[n]:=ne;

end;

ne:=0;

for i:=1 to n do

if (v[i]>=v[1]) and (v[i]<=v[n])

then ne:=ne+1;

interval:=ne;

end;

4.a. Pun pe prima pozitie din sir valoarea 0 apoi citesc elementele īn sir īncepand

cu adoua pozitie. La final alelez functia interval si afisez valoarea returnata

4.b. type sir=array[1..100]of integer;

var f:text;

a:sir;

n,i:integer;

function interval(v:sir; d:byte):byte;

var i,ne:byte;

begin

if v[1]>v[d]

then begin

ne:=v[1];

v[1]:=v[d];

v[d]:=ne;

end;

ne:=0;

for i:=1 to d do

if (v[i]>=v[1]) and (v[i]<=v[d])

then ne:=ne+1;

interval:=ne;

end;

begin

assign(f,'numere.txt'); reset(f);

a[1]:=0;

i:=2;

while not eof(f) do

begin

read(f,a[i]);

i:=i+1;

end;

n:=i-1;

write(interval(a,n)-1);

close(f);

end.

Varianta 18:

b

Rezolvari Subiectul III

function count(v:sir; n:byte):byte;

var i,ne:integer;

begin

ne:=0;

for i:=1 to n do

if v[i]>=(v[1]+v[n])/2

then ne:=ne+1;

count:=ne;

end;

4.a. Pun pe prima pozitie din sir valoarea 0 apoi citesc elementele īn sir īncepand

cu adoua pozitie. La final alelez functia count si afisez valoarea returnata

4.b. type sir=array[1..100]of integer;

var a:sir;

n,i:integer;

f:text;

function count(v:sir; n:byte):byte;

var i,ne:integer;

begin

ne:=0;

for i:=1 to n do

if v[i]>=(v[1]+v[n])/2

then ne:=ne+1;

count:=ne;

end;

begin

assign(f,'numere.txt'); reset(f);

a[1]:=0;

i:=2;

while not eof(f) do

begin

read(f,a[i]);

i:=i+1;

end;

n:=i-1;

write(count(a,n));

close(f);

end.

Varianta 19:

a

type sir=array[1..100]of real;

var a:sir;

n,i:integer;

procedure aranjare(var v:sir; n:byte);

Rezolvari Subiectul III

var i,j:byte; aux:real;

begin

i:=1; j:=n;

while i<j do

begin

while (i<j) and (v[i]<0) do i:=i+1;

while (i<j) and (v[j]>0) do j:=j-1;

if i<j

then begin

aux:=v[i];

v[i]:=v[j];

v[j]:=aux;

end;

end;

end;

begin

write(' n= '); read(n);

for i:=1 to n do

begin

write(' A[',i,']= '); read(a[i]);

end;

aranjare(a,n);

for i:=1 to n do

write(a[i]:7:2,' ');

end.

4.a. Citesc cele 2 numere apoi citesc, pe rand, cate o linie din fisier si o prelucrez

cu ajutorul subprogramului. Linia prelucrata o scriu in fisierul indicat.

4.b. type sir=array[1..100]of real;

var f,g:text;

n,m,i,j:integer;

a:sir;

procedure aranjare(var v:sir; n:byte);

var i,j:byte; aux:real;

begin

i:=1; j:=n;

while i<j do

begin

while (i<j) and (v[i]<0) do i:=i+1;

while (i<j) and (v[j]>0) do j:=j-1;

if i<j

then begin

aux:=v[i];

v[i]:=v[j];

v[j]:=aux;

end;

end;

end;

Rezolvari Subiectul III

begin

assign(f,'nr1.txt'); reset(f);

assign(g,'nr2.txt'); rewrite(g);

readln(f,n,m);

for i:=1 to n do

begin

for j:=1 to m do

read(f,a[j]);

aranjare(a,m);

for j:=m downto 1 do

write(g,a[j]:7:2,' ');

writeln(g);

end;

close(f);

close(g);

end.

Varianta 20:

c

type sir=array[1..100]of real;

var a:sir;

n,i:integer;

procedure nule(var v:sir; n:byte);

var i,j:byte; aux:real;

begin

i:=1; j:=n;

while i<j do

begin

while (i<j) and (v[i]<>0) do i:=i+1;

while (i<j) and (v[j]=0) do j:=j-1;

if i<j

then begin

aux:=v[i];

v[i]:=v[j];

v[j]:=aux;

end;

end;

end;

begin

write(' n= '); read(n);

for i:=1 to n do

begin

write(' A[',i,']= '); read(a[i]);

end;

nule(a,n);

for i:=1 to n do

write(a[i]:7:2,' ');

Rezolvari Subiectul III

end.

4.a. Citesc cele 2 numere apoi citesc, pe rand, cate o linie din fisier si o prelucrez

cu ajutorul subprogramului. Linia prelucrata o scriu in fisierul indicat.

4.b type sir=array[1..100]of real;

var f,g:text;

n,m,i,j:integer;

a:sir;

procedure nule(var v:sir; n:byte);

var i,j:byte; aux:real;

begin

i:=1; j:=n;

while i<j do

begin

while (i<j) and (v[i]<>0) do i:=i+1;

while (i<j) and (v[j]=0) do j:=j-1;

if i<j

then begin

aux:=v[i];

v[i]:=v[j];

v[j]:=aux;

end;

end;

end;

begin

assign(f,'nr1.txt'); reset(f);

assign(g,'nr2.txt'); rewrite(g);

readln(f,n,m);

for i:=1 to n do

begin

for j:=1 to m do

read(f,a[j]);

nule(a,m);

for j:=m downto 1 do

write(g,a[j]:7:2,' ');

writeln(g);

end;

close(f);

close(g);

end.


Document Info


Accesari: 2794
Apreciat: hand-up

Comenteaza documentul:

Nu esti inregistrat
Trebuie sa fii utilizator inregistrat pentru a putea comenta


Creaza cont nou

A fost util?

Daca documentul a fost util si crezi ca merita
sa adaugi un link catre el la tine in site


in pagina web a site-ului tau.




eCoduri.com - coduri postale, contabile, CAEN sau bancare

Politica de confidentialitate | Termenii si conditii de utilizare




Copyright © Contact (SCRIGROUP Int. 2024 )