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
| using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace deuxiemeVersionExerciceEval1
{
class Program
{
static void Main(string[] args)
{
System.IO.StreamReader contenuFichier = new System.IO.StreamReader(@"abcd.txt");
string[] contenuTempo = contenuFichier.ReadToEnd().Split(new string[] { "/n", "/r" }, StringSplitOptions.RemoveEmptyEntries);
Console.WriteLine("Mot à chercher? ");
string motVoulu = Console.ReadLine();
for (int i=0; i < contenuTempo.Length; i++)
{
if (contenuTempo[i] != motVoulu)
{
Console.WriteLine("KO!");
}
else
{
Console.WriteLine("OK!");
if (i > 0) Console.WriteLine("Mot d'avant: " + contenuTempo[i - 1]);
if (i != int.Parse(contenuTempo[i - 1]))
{
Console.WriteLine("Mot d'après: " + contenuTempo[i + 1]);
}
}
}
Console.WriteLine("Appuyez sur une touche pour sortir!");
Console.ReadKey();
}
}
} |
Partager