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
| #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define LV 1
#define LC 1
//Fonction pour afficher un voyelle aléatoirement
void ranVoyelle(){
int i;
char voyelle[LV]={0};
char voy[7]="AEIOUY";
srand(time(NULL));
for ( i=0; i<LV; i++){
voyelle[i]=voy[rand()%6];
}
printf("%s", voyelle);
}
//Fonction pour afficher une consonne aléatoirement
void ranConsonne(){
int j;
char consonne[LC]={0};
char con[21]="BCDFGHJKLMNPQRSTVWXZ";
srand(time(NULL));
for ( j=0; j<LV; j++){
consonne[j]=con[rand()%20];
}
printf("%s", consonne);
}
int main(void)
{
char caractere;
int k;
printf("-Appuiyez sur O pour quitter \n-Appuiyer sur C pour une consonne\n-Appuiyer sur V pour un voyelle\n");
while(caractere!='O'){
caractere=getch();
for (k=0;k<1;k++){
if(caractere == 'V' || caractere == 'v'){
ranVoyelle();
}
else if(caractere == 'C' || caractere == 'c'){
ranConsonne();
}
}
}
return 0;
} |
Partager