Guest User

projet

a guest
Dec 24th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.11 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3. #include<stdlib.h>
  4. void find_words()
  5. {
  6.   char phrase[100] ;
  7.   //input of the sentence
  8.   puts ("Saisir une phrase : \n");
  9.   getchar();
  10.   gets(phrase);
  11.  // variables
  12.   int i;
  13.   int word_begin = 0 ;
  14.   int word_count = 0 ;
  15.   char ch[100][100] ;
  16.   char* word ;
  17. // find the words in the sentence
  18.   for ( i=0 ; i < strlen(phrase); i++ )
  19.   {
  20.     if ( *(phrase+i) == ' ' || *(phrase+i) == '.')
  21.     {
  22.       strncpy(ch[word_count], phrase + word_begin ,i - word_begin)  ;
  23.       word_begin = i + 1 ;
  24.       word_count++ ;
  25.     }
  26.   }
  27.   // affichage des mots
  28.   for (i = 0 ; i < word_count ;i++)
  29.   {printf(" mot %d ", i+1 );
  30.     puts(ch[i]) ;
  31.   }
  32. }
  33. void find_voyelles ()
  34. {
  35.   int a,b, voyelles_count=0;
  36.   char mot[5] ;
  37.   char tab_voyelles[] = {'a','e','o','i','y'};
  38.  
  39.   printf("Donner un mot\n");
  40.   scanf("%s",mot);
  41.   printf(" Les voyelles sont :" );
  42.   for( a=0; a < strlen (mot) ; a++ )
  43.   {
  44.     //printf("%c\n",mot[a] );
  45.     for( b=0; b<5; b++)
  46.     {
  47.       if ( tab_voyelles[b] == mot[a] )
  48.       {
  49.         voyelles_count++;
  50.         printf("%c \t ",tab_voyelles[b] );
  51.       }
  52.     }
  53.   }
  54.  
  55. printf ("\n Le nombre des  voyelles est %d ", voyelles_count );
  56. }
  57. void reorder_sentence()
  58. {
  59. char phrase_propose[]= "C'est notre sixieme prosit pour cette annee.";
  60. int  word_order[]={3,2,5,1,7,4,6};
  61. int  word_order_proposed[7];
  62. int i, ordre,m;
  63.  
  64. // texte a afficher
  65. puts("Donner l'ordre du mot 'sixieme' dans la phrase ");
  66. puts("Donner l'ordre du mot 'notre' dans la phrase ");
  67. puts("Donner l'ordre du mot 'pour' dans la phrase ");
  68. puts("Donner l'ordre du mot 'C'est' dans la phrase ");
  69. puts("Donner l'ordre du mot 'annee' dans la phrase ");
  70. puts("Donner l'ordre du mot 'prosit' dans la phrase ");
  71. puts("Donner l'ordre du mot 'cette' dans la phrase ");
  72. // put the order
  73. for (i=0;i<8;i++)
  74. {
  75. scanf("%d", word_order_proposed );
  76. }
  77. //check the order
  78. for (i=0;i<7;i++)
  79. {
  80. if (word_order[i]== word_order_proposed[i])
  81.  {
  82.    m++;
  83.  }
  84. else abort ;
  85. }
  86. if (m!=6)
  87. {
  88. printf(" Faux! La phrase est : C'est notre sixiéme prosit pour cette année \n " );
  89. }
  90. else
  91. {
  92. printf(" Bravo c'est la bonne réponse \n La phrase est : C'est notre sixiéme prosit pour cette année");
  93. }
  94. }
  95. int main()
  96. {
  97. int n;
  98. // affichage menu
  99.     printf("*******************************************************\n") ;
  100.     printf("1 : Afficher les mots d'une phrase\n");
  101.     printf("2 : Afficher les voyelles et leur nombre dans un mot\n");
  102.     printf("3 : Construire une phrase\n") ;
  103.   printf("0 : Quitter\n") ;
  104.   printf("*******************************************************\n") ;
  105. // choix menu
  106.     do
  107.     {
  108.  
  109.          printf("Veuillez saisir votre choix : \n");
  110.           scanf("%d",&n);
  111.         printf("mon choix est %d \n",n);
  112.    }
  113.     while((n!=0)&&(n!=1)&&(n!=2)&&(n!=3));
  114. // instruction 1 :
  115.   if (n==1)
  116.   {
  117.     find_words();
  118.   }
  119.   // instruction 2 : trouver les voyelles d'un mot / nbre de voyelles
  120.   if (n==2)
  121.   {
  122.     find_voyelles();
  123.   }
  124.   // instruction3 :  Construire une phrase
  125.   if (n==3)
  126.   {
  127.     reorder_sentence();
  128.   }
  129.  return 0;
  130. }
  131. // thank you for your help cousin I really appericiate it <3 <3 <3 <3
Advertisement
Add Comment
Please, Sign In to add comment