1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| int main()
{
//comptons large... 10 caractères effectifs, ca semble pas mal ;)
char nombre[11];
int verif;
int affiche=0;
int cpt=0;
printf("Intrudisez un nombre entre 1 et 31000\n");
fgets(nombre,10,stdin);
//autant vérifier la validité de l'introduction ici
verif=atoi(nombre);
if(verif<1 || verif>31000)
affiche=2;
while(cpt<6 && affiche==0)
{
//si on trouve un '3' dans la chaine, c'est bon ;)
if(nombre[cpt]=='3')
affiche=1;
cpt++;
}
if(affiche==1)
printf("%d",nombre);
if(affiche==2)
printf("la valeur introduite n'est pas valable");
return 0;
} |