Page 97 - MATINF Nr. 3
P. 97
˘
PROBLEME DE INFORMATICA PENTRU EXAMENE 97
a) 20 b) 0 c) 180 d) 24
5. Se consider˘a programul:
Varianta Pascal Varianta C/C++
#include <iostream.h>
var i,j:integer;
using namespace std;
a:array [1..6 ,1..6] of integer;
int main (){
begin
int i,j,a[7][7];
for i:=1 to 6 do
for(i=1;i<7;i++)
for j:=1 to 6 do
for(j=1;j<7;j++)
a[i,j]:=0;
a[i][j]=0;
for i:=2 to 6 do
for(i=2;i<7;i++)
for j:=2 to 6 do
for(j=2;j<7;j++)
a[i,j]:=i*j mod 6;
a[i][j]=i*j%6;
for i:=1 to 3 do
for(i=1;i<4;i++){
begin
for(j=1;j<4;j++)
for j:=1 to 3 do
cout <<a[i][j];
write(a[i,j]);
cout <<endl;
writeln;
}
end;
return 0;
end.
}
Dup˘a executare, se va afi¸sa:
a) 123 b) 000 c) 000 d) 000
240 240 040 240
303 003 003 303
6. Se consider˘a:
Varianta Pascal Varianta C/C++
function ex(k:longint ): integer; int ex(long k){
begin if (k==0)
if k=0 then return 1;
ex:=1 else
else if(k%10!=0)
if k mod 10<>0 then return ex(k/10)*(k%10);
ex:=ex(k div 10)*(k mod 10) else
else return ex(k/10);
ex:=ex(k div 10); }
end;
Care este valoarea expresiei: ex(192) + ex(2019)?
a) 7 b) 24 c) 36 d) 18
7. Se consider˘a un arbore cu 11 noduri, r˘ad˘acina ˆın nodul 2 ¸si muchiile [2, 3], [3, 1], [3, 4],
[4, 7], [4, 6], [1, 5], [1, 9], [1, 10], [7, 8], [2, 11]. Care din vectorii urm˘atori este vector tat˘a?
a) T=(3, 0, 2, 0, 1, 4, 4, 7, 1, 1, 2) b) T=(3, 0, 2, 3, 1, 4, 4, 7, 1, 1, 2)
c) T=(3, 0, 2, 3, 1, 4, 4, 1, 1, 1, 2) d) T=(3, 3, 0, 3, 1, 4, 4, 7, 1, 1, 2)
8. Cˆate frunze (noduri terminale) are arborele de la problema 7?