Sunteți pe pagina 1din 5

Bac 2020 testul 2

Subiectul 1

Ex1. dx+20>=0&&x-20<=0

Ex2. c 1990

Ex3. a- bentita,racheta,sapca //b. (fileu, grip, mingi, șapcă) -4p

Ex4 b-(2,0,1,1,2,1)

Ex5 b – 2 //a)1 (6,2) -4p

Subiectul 2

Ex1. a.295 //20950 -6p

b. 60804,20406,80602

c. #include <iostream>

using namespace std;

int main()

{ int n,m,c;

cin>>n;

m=0;

do

{c=n%10;

n=n/10;

if(c==0) c=2;

else if(c%2==0)c=0;

m=m*10+c;

}while(n==0) // while(n!=0) !!! executa – cat timp ! (cond) -1p

cout<<m;

return 0;

repeta executa A

A -> A -> cat timp !(cond)

Pana cand (cond) Cat timp !(cond) A

D. Citeste n

m<-0
c<-n%10

daca c=0 atunci c<-2

Altfel

Daca c%2=0 atunci c<-0

m<-m*10+c

Cat timp n!=0 executa

{ c<-n%10

daca c=0 atunci c<-2

{ Altfel

{ Daca c%2=0 atunci c<-0 }

m<-m*10+c

Scrie m

Ex2. struct specia

{int cod,nrExemplare;

Int varsta[9];

}s[19];

Ex3. #include <iostream>

using namespace std;

int main()

{ int i,j,a[5][7];

for(i=0;i<5;i++)

for(j=0;j<7;j++)

a[i][j]=1;

for(i=1;i<5;i++)

for(j=1;j<7;j++)

a[i][j]=(a[i][j-1]+a[i-1][j])%10;

If(i==0 || j==0) a[i][j]=1;

Else a[i][j]=(a[i][j-1]+a[i-1][j])%10;

for(i=0;i<5;i++)

{for(j=0;j<7;j++)
cout<<a[i][j]<<" ";

cout<<endl; }

return 0;

Subiectu 3

Ex1.#include <iostream>

using namespace std;

void fii(long n)

{int i ;

for(i=n;i>3;i--)

if(n%i==0 && n/i!=i) {cout<<'('<<i<<" ";

cout<<n/i<<')'<<" ";}

int main()

{ int n;

cin>>n;

fii(n);

return 0;

Ex2. #include <iostream> -6p

#include <cstring>

using namespace std;

int main()

{int i,p=0,k,j;

char s[100],cuv[100],t[100];

gets(s);

i=0;
while(i<strlen(s))

{while(s[i]==' '&& i<strlen(s)) i++;

k=-1;

while(s[i]!=' '&& i<strlen(s)) {k++;

cuv[k]=s[i];

i++;}

cuv[++k]='\0';

//niciuna din aceste variante nu-mi merge,nu reusesc decat sa salvez primul cuvant, nu stiu

I. //for(j=0;j<=k;j++)

//if (!(cuv[j]=='-'&&cuv[j+1]>=0&&cuv[j+1]<=9)) {t[p++]=cuv[j]; cout<<t<<" ";}

//else j++;

Ii.for(j=0;j<=k;j++)

if(cuv[j]=='-'&& !(cuv[j+1]>='a'&&cuv[j+1]<='z')) { strcpy(cuv,cuv+1); j--;}

else t[p++]=cuv[j];

t[p]='\0';

strcpy(s,t);

cout<<s;

return 0;

int main()

{char s[256],cuv[25],s1[256];

int i,j,k=0;

gets(s);

strcat(s," ");

for(i=0;i<strlen(s);i++)

if(s[i]!=' ') cuv[k++]=s[i];

else {cuv[k]='\0';

if(k>0){if(cuv[0]!='-') {strcat(s1,cuv);strcat(s1," ");}

k=0;

}
strcpy(s,s1);

cout<<s;

Ex3. #include <iostream>

#include <fstream>

using namespace std;

ifstream fin("bac.in");

int main()

{int maxi1=INT_MIN,maxi2=INT_MIN,maxi3=INT_MIN;

long x;

while(fin>>x)

if(x%10==0 && x/10%10==2)

if(x>maxi3) {maxi3=maxi2;

maxi2=maxi1;

maxi1=x;

else if(x>maxi2 &&maxi2!=maxi1) {maxi2=maxi1; //nu e nevoie,,,nr distincte din


enunt

maxi1=x;}

else if(x>maxi1 &&maxi1!=maxi2 &&maxi1!=maxi3)

maxi1=x;

cout<<maxi1<<" "<<maxi2<<" "<<maxi3<<" ";

fin.close();

return 0;