Bac Info 2020 Testul 1
Bac Info 2020 Testul 1
Bac Info 2020 Testul 1
Sub I
1. a
2. C
3. D
4. B
5. C
Sub II:
B: - 49,189,243
- 49,79,543
C: #include <iostream>
int main()
{int n,p,m,k,x,c,i;
p=1;m=0;k=0;
while(n!=0)
{cin>>x;
for(i=1;i<=k;i++)
x=x/10;
if(x!=0)c=c%10;
else c=n%10;
m=c*p+m;
n=n/10;
p=p*10;
k=k+1;
cout<<m;
return 0;
}
D: citeste n // -6p
p←1; m←0; k←0
cat timp n≠0 executa
{ citeste x
x←[x/p]
daca x≠0 atunci c←x%10
altfel c←n%10
m←c*p+m
n←[n/10]
p←p*10; k←k+1
}
scrie m
2. Struct triunghi
{struct
Int t[6];???
3. 8 viCtORIe
Subiectul III
1. #include <iostream>
#include <cmath>
{int u,max=INT_MIN;
d=2;
while(n!=0) //(n!=1)
{p=0;
while(n%d==0) {p=p+1;
n=n/d;
if(p>=max) {max=p;
u=d;}
d=d+1;
d=u; p=max;
int main()
{int n,d,p;
cin>>n;
putere(n,d,p);
cout<<d<<p;
return 0;
2. Inserez poza de la cod pentru ca nu inteleg de ce imi pune pe ultimele 2 coloane de pe linia
intai cifra 2,astefl stricand tot ce e mai jos. El in rest imi pune toate valorile din exemplu . a[10][10]
#include <iostream>
#include <cmath>
int main()
cin>>n>>k;
for(i=1;i<=n*k;i++)
if(nr<k) {a[1][i]=x;
nr=nr+1;}
else {x=x+1;
a[1][i]=x;
nr=1;
for(i=2;i<=n+1;i++)
for(j=1;j<=n*k;j++)
a[i][j]=a[i-1][j]+1;
for(i=1;i<=n+1;i++)
{for(j=1;j<=n*k;j++)
cout<<a[i][j]<<" ";
cout<<endl;}
return 0;
sau
cin>>n>>k;
for(i=1;i<=n;i++)
for(j=1;j<=n*k;j++)
if(j==1) {x=i; a[i][j]=x; }
else {
a[i][j]=x;
if(j%k==0) x++;
}
3. #include <iostream>
#include <fstream>
using namespace std;
ofstream fout("bac1.txt");
int main()
{long y ,x,z;
cin>>x>>y;
if(y>1 &&x>1)
do {z=3*x-y;
y=x;
x=z;
fout<<z<<" ";
} while(y!=1 || x!=1);
return 0;