using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Exercice5._6Modifie { class Program { static void Main(string[] args) { /*Énoncé : Écrire un programme qui lit un texte et compte * le nombre de voyelles dans ce texte et affiche : 1-le nombre total de caractère 2-le nombre total de voyelles 3-le nombre total d'espace 4-la position de la première voyelle */ //Déclaration des variables string texte; int cpt = 0, cptEspace = 0, position = -1; Console.Write("Donnez-moi votre texte: "); texte = Console.ReadLine(); for (int i = 0; i < texte.Length; i++) {//compter le nombre de voyelles y compri les majuscules if ((texte[i] == 'a') || (texte[i] == 'e') || (texte[i] == 'i') || (texte[i] == 'o') || (texte[i] == 'y') || (texte[i] == 'u') || (texte[i] == 'A') || (texte[i] == 'O') || (texte[i] == 'E') || (texte[i] == 'Y') || (texte[i] == 'I') || (texte[i] == 'U')) { if (cpt == 0) { position = i;//la position de la première voyelle } cpt++; }//compter le nombre d'espace else if ((texte[i] == ' ')) { cptEspace++; } } Console.WriteLine("Le nombre de caractèrs = {0}", texte.Length); Console.WriteLine("Le nombre de voyelles = {0} et le nombre d'espaces= {1}", cpt, cptEspace); if (position >= 0) { Console.WriteLine("La position de la première voyelle: {0}", position+1); } Console.Read(); } } }