Varianta 28 bacalaureat informatica 2007

Cerinte si rezolvari

{pdf=pdf/bacalaureat2007/varianta_028.pdf|600|600}
Rezolvari
1)
#include<iostream.h>
#include<math.h>
long a,v[11],i,j,ok=1;
void fct()
{

int x=a%10;
v[1]=x;
int y=x;
for(i=2;i<=10;i++)
{
y=y*x;
v[i]=y%10;
if(v[i]==v[1])
i=11;
else
ok++;

}
}
void main()
{
cin>>a;
fct();
int n=2007%ok;
cout<<v[n];

}
2)
#include<iostream.h>
int a[101][101],i,j,n;
void fct()
{
for(j=1;j<=n;j++)
a[1][j]=j;
for(i=2;i<=n;i++)
for(j=1;j<=n;j++)
{
if(a[i-1][j+1]==0)

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

else
a[i][j]=a[i-1][j+1];
}
}
void afis()
{
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
cout<<a[i][j]<<" ";
cout<<endl;
}
}
void main()
{
cin>>n;
fct();
afis();
}
3)
#include<iostream.h>
#include<math.h>
long k;
int panta(long n)
{
long k=n;
int max=0;
int min=9;
while(k)
{
if(k%10>max)
max=k%10;
k/=10;
}
while(n)
{
if(n%10<min)
min=n%10;
n/=10;
}
return max-min;
}
void main()
{
cin>>k;
int c=log10(k);
if(panta(k)==c)
cout<<"DA";
else
cout<<"NU";
}