Varianta 31 bacalaureat informatica 2007

Cerinte si rezolvari

https://docs.google.com/open?id=0B1q_aP8fl4RdZWRmNzNmNWEtMjE5MC00YmU0LWI5ZDgtMjI4N2JkZTM4MGI0

Rezolvari
1)
#include<iostream.h>
#include<math.h>
int max_diviz(long a,long b)
{
if(a==b)
{
int l=log10(a)+1;
if(l==2)
return a;
else
return 1;
}
else
{
if(a>b)
return max_diviz(a-b,b);
else
return max_diviz(a,b-a);
}
}
void main()
{
long a;
cin>>a;
int max=1;
for(int i=99;i>=10;i--)
{
int t=max_diviz(a,i);
if(t!=1)
{
if(t>max)
max=t;
}
}
cout<<max;
}
2)
#include<fstream.h>
ifstream f("matrice.in");
int n,m,a[11][11],i,j,k,t;
void citire()
{
f>>n>>m;
for(i=1;i<=n;i++)
for(j=1;j<=m;j++)
f>>a[i][j];
}
void fct()
{
for(j=1;j<=m;j++)
{
int ok=1;
for(i=1;i<n;i++)
for(k=i+1;k<=n;k++)
if(a[i][j]==a[k][j])
ok=0;
if(ok)
t++;
}
}
void main()
{
citire();
fct();
cout<<t;
}
3)
#include<iostream.h>
#include<string.h>
struct nod
{
char info[100];
nod * adr;
};
nod *p,*q,*u;
int n;
void creare(nod *&p)
{
q=new nod;
cout<<"dati inf: ";cin>>q->info;
q->adr=NULL;
p=q;
u=p;
for(int i=2;i<=n;i++)
{
q=new nod;
cout<<"dati inf: ";cin>>q->info;
u->adr=q;
q->adr=NULL;
u=q;
}
}
nod * cautare(nod *&p, char x[100])
{
nod *r=NULL;
for(q=p;q;q=q->adr)
if(strcmp(q->info,x)==0)
r=q;
return r;
}
void afis()
{
for(q=p;q;q=q->adr)
cout<<q->info<<" ";
}
void main()
{
cin>>n;
char v[12]={"bacalaureat"};
creare(p);
if(cautare(p,v))
cout<<"Cuvantul bacalaureat a fost gasit in lista";
else
cout<<"Cuvantul bacalaureat nu a fost gasit in lista";
}