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 27 28 29 30 31 32 33 34
| int main(int argc, char *argv[])
{
int i;
int *tab;
tab=(int *)malloc(i*sizeof(int));
int nombre_recherche=0;
int nb=0;
printf("Ce programme permet de trouver toutes les occurrences d'un nombre.\n");
printf("Entrer 10 nombres:\n");
for (i=0;i<10;i++)
{
printf("t[%d]: ",i);
scanf("%d",&tab[i]);
}
printf("Entrez le nombre a rechercher : ");
scanf("%d",&nombre_recherche);
for (i=0;i<10;i++)
{
if (tab[i] == nombre_recherche)
{
printf("t[%d],",i);
nb++;
}
}
printf("\n%d occurent(s) trouve(s).\n",nb);
free(tab); |
Partager