Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- #include<stdlib.h>
- void find_words()
- {
- char phrase[100] ;
- //input of the sentence
- puts ("Saisir une phrase : \n");
- getchar();
- gets(phrase);
- // variables
- int i;
- int word_begin = 0 ;
- int word_count = 0 ;
- char ch[100][100] ;
- char* word ;
- // find the words in the sentence
- for ( i=0 ; i < strlen(phrase); i++ )
- {
- if ( *(phrase+i) == ' ' || *(phrase+i) == '.')
- {
- strncpy(ch[word_count], phrase + word_begin ,i - word_begin) ;
- word_begin = i + 1 ;
- word_count++ ;
- }
- }
- // affichage des mots
- for (i = 0 ; i < word_count ;i++)
- {printf(" mot %d ", i+1 );
- puts(ch[i]) ;
- }
- }
- void find_voyelles ()
- {
- int a,b, voyelles_count=0;
- char mot[5] ;
- char tab_voyelles[] = {'a','e','o','i','y'};
- printf("Donner un mot\n");
- scanf("%s",mot);
- printf(" Les voyelles sont :" );
- for( a=0; a < strlen (mot) ; a++ )
- {
- //printf("%c\n",mot[a] );
- for( b=0; b<5; b++)
- {
- if ( tab_voyelles[b] == mot[a] )
- {
- voyelles_count++;
- printf("%c \t ",tab_voyelles[b] );
- }
- }
- }
- printf ("\n Le nombre des voyelles est %d ", voyelles_count );
- }
- void reorder_sentence()
- {
- char phrase_propose[]= "C'est notre sixieme prosit pour cette annee.";
- int word_order[]={3,2,5,1,7,4,6};
- int word_order_proposed[7];
- int i, ordre,m;
- // texte a afficher
- puts("Donner l'ordre du mot 'sixieme' dans la phrase ");
- puts("Donner l'ordre du mot 'notre' dans la phrase ");
- puts("Donner l'ordre du mot 'pour' dans la phrase ");
- puts("Donner l'ordre du mot 'C'est' dans la phrase ");
- puts("Donner l'ordre du mot 'annee' dans la phrase ");
- puts("Donner l'ordre du mot 'prosit' dans la phrase ");
- puts("Donner l'ordre du mot 'cette' dans la phrase ");
- // put the order
- for (i=0;i<8;i++)
- {
- scanf("%d", word_order_proposed );
- }
- //check the order
- for (i=0;i<7;i++)
- {
- if (word_order[i]== word_order_proposed[i])
- {
- m++;
- }
- else abort ;
- }
- if (m!=6)
- {
- printf(" Faux! La phrase est : C'est notre sixiéme prosit pour cette année \n " );
- }
- else
- {
- printf(" Bravo c'est la bonne réponse \n La phrase est : C'est notre sixiéme prosit pour cette année");
- }
- }
- int main()
- {
- int n;
- // affichage menu
- printf("*******************************************************\n") ;
- printf("1 : Afficher les mots d'une phrase\n");
- printf("2 : Afficher les voyelles et leur nombre dans un mot\n");
- printf("3 : Construire une phrase\n") ;
- printf("0 : Quitter\n") ;
- printf("*******************************************************\n") ;
- // choix menu
- do
- {
- printf("Veuillez saisir votre choix : \n");
- scanf("%d",&n);
- printf("mon choix est %d \n",n);
- }
- while((n!=0)&&(n!=1)&&(n!=2)&&(n!=3));
- // instruction 1 :
- if (n==1)
- {
- find_words();
- }
- // instruction 2 : trouver les voyelles d'un mot / nbre de voyelles
- if (n==2)
- {
- find_voyelles();
- }
- // instruction3 : Construire une phrase
- if (n==3)
- {
- reorder_sentence();
- }
- return 0;
- }
- // thank you for your help cousin I really appericiate it <3 <3 <3 <3
Advertisement
Add Comment
Please, Sign In to add comment