Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace ConsoleApp10
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- string path = "file.txt";z
- string text = "root startsart faaaasast";
- string smax; //slovo
- string s = "";
- int kmax = 0; //chetchik
- int km = 0;
- int k = 0;
- char[] g = { 'a', 'e', 'i', 'o', 'u', 'y' };
- char[] consonants = { 'b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'z' };
- // полная перезапись файла
- using (StreamWriter writer = new StreamWriter(path, false))
- {
- string ntxt = "";
- foreach (char c in text)
- {
- if (g.Contains(c) || consonants.Contains(c) || c == ' ')
- {
- ntxt += c;
- }
- }
- writer.WriteLine(ntxt);
- }
- using (StreamReader reader = new StreamReader(path))
- {
- while (reader.Peek() != -1) //peek смотрит какой символ впереди. если конец файла - возвращает -1
- {
- char a = (char)reader.Read(); //считываем и смещаем на след символ
- if (a == ' ')
- {
- if (km > kmax)
- {
- kmax = km;
- smax = s;
- k = 0;
- }
- continue;
- }
- s += a;
- if (!g.Contains(a))
- {
- k++;
- if (k > km)
- {
- km = k;
- }
- }
- else
- {
- k = 0;
- }
- }
- Console.WriteLine(s);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement