P. 1
Rezolvari informatica intensiv si neintensiv bacalaureat 2008

Rezolvari informatica intensiv si neintensiv bacalaureat 2008

4.9

|Views: 380,907|Likes:
Published by MelittaKrestel
Rezolvari informatica intensiv si neintensiv bacalaureat 2008
Rezolvari informatica intensiv si neintensiv bacalaureat 2008

More info:

Published by: MelittaKrestel on Feb 25, 2009
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF or read online from Scribd
See more
See less

12/05/2015

pdf

original

SUBIECTUL I
1.
a.
2.
a)
593
b) Orice număr format doar din cifre pare. Exemplu: 13579
c)
Varianta C/C++

Varianta PASCAL

#include
void main()
{

long int a,b,p,c;
cin>>a;
b=0; p=1;
while (a)
{

c=a%10;
if(c%2!=0)
{
b=b+p*c;
p=p*10;

}
a=a/10;

}
cout<

}

var a,b,p,c:longint;

begin
readln(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;
writeln(b);
end.

d) citeste a
b 0
p 1
┌ execută
│ c a%10
│ ┌dacă c%2≠0 atunci

Bacalaureat 2008 – Modele de rezolvare

269

b b+p*c

p p*10


│ a [a/10]
└ cât timp a>0
scrie b

SUBIECTUL II
1.
d
2. pentru intensiv c, pentru neintensiv d
3.
6
4. pentru intensiv 2, pentru neintensiv 5, 4, 3
5.
Varianta C/C++

Varianta PASCAL

#include
#include
void main()
{

char s[20],aux[20];
int n,k;
cin>> s;
n=strlen(s);
if (n%2==0)
{

k=n/2;
strcpy(aux,s+k);
strncat(aux,s,k);
cout<

}
else
{

k=n/2;
strcpy(aux,s+k+1);
strncat(aux,s+k,1);
strncat(aux,s,k);
cout<

}

}

var s,aux:string[20];
n,k:byte;

begin
readln(s);
n:=length(s);
aux:='';
if n mod 2=0 then
aux:=concat(copy(s,n div 2+1,n
div 2), copy(s,1,n div 2))
else
aux:=concat(copy(s,n div 2+2,n
div 2), copy(s,n div
2+1,1),copy(s,1,n div 2));
writeln(aux);
end.

SUBIECTUL III
1.
b
2. 11
3. pentru intensiv
Varianta C/C++

Varianta PASCAL

#include
ifstream fin("fisier.in");
int v[1000],n,i,j,x,aux;
int cif_egale(int x)
{

int ok=1;
while(ok && x>10)
{

if (x%10!=x/10%10) ok=0;
x=x/10;

}
return ok;

var x,i,j,aux,n:integer;
v:array[1..1000] of integer;
fin:text;

function
cif_egale(x:integer):boolean;
var ok:boolean;
begin
ok:=true;
while ok and (x>10) do
begin
if x mod 10<>x div 10 mod 10

then ok:=false;

Bacalaureat 2008 – Modele de rezolvare

270

}
void main()
{

fin>>x;
while(!fin.eof())
{

if(cif_egale(x)) { n++;

v[n]=x; }

fin>>x;

}
for(i=1;i<=n-1;i++)
for(j=i+1;j<=n;j++)
if (v[i]>v[j])
{

aux=v[i];
v[i]=v[j];
v[j]=aux;

}
for(i=1;i<=n;i++) cout<

}

x:=x div 10;
end;
cif_egale:=ok;
end;
begin
assign(fin,'fisier.in');
reset(fin);
n:=0;
read(fin,x);
while (not eof(fin)) do
begin
if (cif_egale(x)) then
begin
inc(n);
v[n]:=x;
end;
read(fin,x);
end;
for i:=1 to n-1 do
for j:=i+1 to n do
if v[i]>v[j] then
begin
aux:=v[i];
v[i]:=v[j];
v[j]:=aux;
end;
for i:=1 to n do
write(v[i],' ');

close(fin);
end.

pentru neintensiv
Varianta C/C++

Varianta PASCAL

void patrat(int n,int v[])
{

int i,j=0;
for(i=1;i<=n;i++)

{

if (sqrt(v[i])==(int)sqrt(v[i]))
{cout< j++;}
if(j%10==0) cout<

}

}

procedure patrat(n:integer; v:array
of integer);
var i,j:integer;
begin
j:=0;
for i:= 1 to n do
begin
if
(sqrt(v[i])=trunc(sqrt(v[i]))) then
begin
write(v[i],' ');
inc(j);
end;
if j mod 10=0 then writeln;
end;

end;

4. pentru intensiv
a)
Varianta C/C++

Varianta PASCAL

void cif_dis(long n, int &d)
{

long cn;
short k,c;
d=1;
while(n && d)
{

cn=n;

procedure cif_dis(n:longint;var
d:boolean);
var cn:longint;
k,c:byte;

begin
d:=true;
while (n>0) and d do
begin

Bacalaureat 2008 – Modele de rezolvare

271

k=1;
c=cn%10; cn=cn/10;
while(cn)
{

if (cn%10==c) k++;
cn/=10;

}
if (k>1) d=0;
n=n/10;

}

}

cn:=n;
k:=1;
c:=cn mod 10; cn:=cn div 10;
while (cn>0) do
begin
if cn mod 10 = c then inc(k);
cn:=cn div 10;
end;
if k>1 then d:=false;
n:=n div 10;
end;

end;

b)

Varianta C/C++

Varianta PASCAL

#include
int n,i,ok;
long v[100];
void cif_dis(long n, int &d)
{

long cn;
short k,c;
d=1;
while(n && d)
{

cn=n;
k=1;
c=cn%10; cn=cn/10;
while(cn)
{

if (cn%10==c) k++;
cn/=10;

}
if (k>1) d=0;
n=n/10;

}

}
void main()
{

cin>>n;
for(i=1;i<=n;i++)
cin>>v[i];
for(i=1;i<=n;i++)
{

cif_dis(v[i],ok);
if (ok) cout<

}

}

Var v:array[1..100] of longint;
n,i:integer;
ok:boolean;
procedure cif_dis(n:longint;var
d:boolean);
var cn:longint;
k,c:byte;

begin
d:=true;
while (n>0) and d do
begin
cn:=n;
k:=1;
c:=cn mod 10; cn:=cn div 10;
while (cn>0) do
begin
if cn mod 10 = c then inc(k);
cn:=cn div 10;
end;
if k>1 then d:=false;
n:=n div 10;
end;

end;
begin
readln(n);
for i:= 1 to n do
read(v[i]);
for i:=1 to n do
begin
cif_dis(v[i],ok);
if ok then write(v[i],' ');
end

end.

pentru neintensiv
a)
Varianta C/C++

Varianta PASCAL

int ordonat(long n)
{

int x=n,ordc=1,ordd=1;
while ((x/10) && ordc)
{

if(x%10<=x/10%10) ordc=0;
x/=10;

}
if (!ordc)

function ordonat(n:longint):boolean;
var x:integer;
ordc,ordd:boolean;

begin
ordc:=true; ordd:=true;
while (x div 10 <>0) and (ordc) do
begin
if x mod 10<=x div 10 mod 10

then ordc:=false;

Bacalaureat 2008 – Modele de rezolvare

272

while ((n/10) && ordd)
{

if(n%10>=n/10%10) ordd=0;
n/=10;

}
if (ordc||ordd) return 1;
else return 0;

}

x:=x div 10;
end;
if not ordc then
while (n div 10>0) and (ordd) do
begin
if n mod 10 >=n div 10 mod 10 then

ordd:=false;
n:=n div 10;
end;
if (ordc) or (ordd) then
ordonat:=true

else

ordonat:=false;
end;

b)
Varianta C/C++

Varianta PASCAL

#include
ifstream fin("numere.in");
int ordonat(long n)
{

int x=n,ordc=1,ordd=1;
while ((x/10) && ordc)
{

if(x%10<=x/10%10) ordc=0;
x/=10;

}
if (!ordc)
while ((n/10) && ordd)
{

if(n%10>=n/10%10) ordd=0;
n/=10;

}
if (ordc||ordd) return 1;
else return 0;

}
void main()
{

long n,x,i;
fin>>n;
for(i=1;i<=n;i++) {fin>> x;
if(ordonat(x)) cout< }
fin.close();

}

VAR fin:text;
n,x,i:integer;
function ordonat(n:longint):boolean;
var x:integer;
ordc,ordd:boolean;

begin
ordc:=true; ordd:=true;
while (x div 10 <>0) and (ordc) do
begin
if x mod 10<=x div 10 mod 10

then ordc:=false;
x:=x div 10;
end;
if not ordc then
while (n div 10>0) and (ordd) do
begin
if n mod 10 >=n div 10 mod 10 then

ordd:=false;
n:=n div 10;
end;
if (ordc) or (ordd) then
ordonat:=true

else

ordonat:=false;
end;
BEGIN
assign(fin,'numere.in');
reset(fin);
readln(fin,n);
for i:=1 to n do
begin
read(fin,x);
if ordonat(x) then write(x,' ');
end;
close(fin);
END.

Bacalaureat 2008 – Modele de rezolvare

273

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->