Varianta 23 bacalaureat informatica 2007

Cerinte si rezolvari

{pdf=pdf/bacalaureat2007/varianta_023.pdf|600|600}

1)

#include<iostream.h>
int n,a[101],i,j;
void citire()
{
cin>>n;
for(i=1;i<=n;i++)
cin>>a[i];
}

void fct()
{
int ok=1;
for(i=1;i<n;i++)
for(j=i+1;j<=n;j++)
if((i==j/2 || j==i/2) && a[i]==a[j])
ok=0;
if(ok==1)
cout<<"corect";
else
cout<<"incorect";
}

void main()
{
citire();
fct();
}
2)
#include<iostream.h>
int k;
long n;
void fct()
{
int c=n/k;
int r=n%k;
for(int i=1;i<=r;i++)
cout<<c+1<<" ";
while(c)
{
for(int j=1;j<=k;j++)
{
cout<<c<<" ";
}
c--;
}
}
void main()
{
cin>>k>>n;
fct();
}
3)
#include<iostream.h>
struct nod {
int info;
nod * urm;
};
nod *p,*q,*u;
int n;
void creare()
{
p=new nod;
cin>>p->info;
p->urm=NULL;
u=p;
for(int i=2;i<=n;i++)
{
q=new nod;
cin>>q->info;
q->urm=NULL;
u->urm=q;
u=q;
}
}
int numar(nod *&p)
{
int ok=0;
for(q=p;q;q=q->urm)
ok++;
return ok;
}

void afis()
{
for(q=p;q;q=q->urm)
cout<<q->info<<" ";
}
void main()
{
cin>>n;
creare();
cout<<numar(p);
}