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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
| void main (void)
{
/* Les déclarations */
char chaine[128],
tabLettres[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
float tabValeurs[27];
unsigned int i;
char* ptrScrut;
int posx,posy;
do
{
/* Titre */
clrscr();
gotoxy(12,2);
puts("***** chaines de caracteres *****");
gotoxy(12,3);
puts("* Auteur : Martins Alexis *");
gotoxy(12,4);
puts("***** Date : 02/11/07 *****");
/* Saisie de la chaine */
gotoxy(1,8);
clreol();
printf("Saisir votre chaine (127 caracteres maxi): ");
gets(chaine);
/* Affichage de la chaine */
clrscr();
gotoxy(12,2);
puts("Voici le pourcentage des differentes lettres employees :");
gotoxy(2,4);
printf("Rappel de la chaine : %s",chaine);
/* Recherche des occurences */
for (i=0;i<27;i++)
{
tabValeurs[0]=0;
ptrScrut = strchr(chaine,tabLettres[0]);
while (ptrScrut!=NULL)
{
tabValeurs[0]= tabValeurs[0]++;
ptrScrut=strchr(ptrScrut+1,tabLettres[0]);
}
/* Affichage du nombre d'occurences */
posx = 20;
posy = 8;
gotoxy(posx,posy);
printf("\n\t\t%c: %5.2f\t%c: %5.2f\n",tabLettres[0],tabValeurs[0],tabLettres[0+1],tabValeurs[0+1]);
tabValeurs[0++];
}
/* Calcul des pourcentages */
puts("\n\nUn autre traitement?'O' ou 'o' ou touche qcq pour quitter : ");
}
while(toupper(getche()) =='O');
} |