

Concours INPT 2010 Informatique :
Corrigé :
Question 1 :
int valide(char t[])
{
int i=0,j=0;
while(t[j]!='\0')
j++;
while(t[i]!='#')
i++;
while(t[j]!='#')
{
if((t[i]=='A'&& t[j]!='T')||(t[i]=='T'&& t[j]!='A')||(t[i]=='C'&& t[j]!='G')||(t[i]=='G'&& t[j]!='C'))
{
return 0;
}
i--;
j--;
}
return 1;
}
Question 2 :
int nombredebase(char t[])
{
int i=0;
while(t[i]!='#')
i++;
return 2*i;
}
Question 3 :(Les pointeurs sont obligatoire ici car on a besoin de deux valeurs et on peux pas faire ( return ) 2 fois dans une fonction )
void pourcentage(char t[], int *a,int *b)
{
int i=0,j=0,k=0;
while(t[i]!='\0')
{
if(t[i]=='A')
j++;
if(t[i]=='T')
k++;
i++;
}
*a=j; *b=k;
}
Aucun commentaire:
Enregistrer un commentaire