Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.IO;
- using System.Threading.Tasks;
- namespace ConsoleApp14
- {
- class Program
- {
- static void Main(string[] args)
- {
- const string CFd = "..\\..\\tekstas.txt";
- const string CFr = "..\\..\\rez.txt";
- char[] skyrikliai = { ' ', '.' };
- string sk = new string(skyrikliai);
- skaitoraso(CFd, CFr,sk);
- //string[] ilgiausias = new string[100];
- string zodis="";
- int me = -1;
- RastiZTekste(CFd, sk, out zodis, ref me);
- if (me > 0)
- {
- Console.WriteLine("ilgzod:{0}", zodis);
- }
- //else Console.WriteLine("nera");
- }
- static void skaitoraso(string fv, string fr, string sk)
- {
- int kiekis = 0;
- using (StreamReader reader = new StreamReader(fv, Encoding.GetEncoding(1257)))
- {
- string line;
- while ((line = reader.ReadLine()) != null)
- {
- //Balsiusk(line);
- //Console.WriteLine(Balsiusk(line));
- //Console.WriteLine(RastiZodiEil(line, sk));
- }
- }
- }
- static int Balsiusk(string e)
- {
- int kiek = 0;
- char[] balses = { 'a', 'o', 'u', 'i', 'e', 'y' };
- for (int i = 0; i < balses.Length; i++)
- {
- if (e.IndexOf(balses[i]) >= 0)
- kiek++;
- }
- return kiek;
- }
- static string RastiZodiEil(string e, string sk)
- {
- //char[] mas = sk.ToCharArray();
- string ilgzod = "";
- string tuscias = "";
- string[] parts = e.Split(sk.ToArray(), StringSplitOptions.RemoveEmptyEntries);
- foreach (string zodis in parts)
- if (zodis.Length > ilgzod.Length && Balsiusk(e) >= 3)
- ilgzod = zodis;
- else return tuscias;
- return ilgzod;
- }
- static void RastiZTekste(string fv, string sk, out string zod, ref int me)
- {
- string[] lines = File.ReadAllLines(fv, Encoding.GetEncoding(1257));
- zod = "";
- me = -1;
- int ilgis = 0;
- int j = 0;
- foreach (string line in lines)
- {
- if (RastiZodiEil(line, sk).Length > 0 && RastiZodiEil(line, sk).Length > zod.Length)
- {
- zod = RastiZodiEil(line, sk);
- ilgis = RastiZodiEil(line, sk).Length;
- j++;
- }
- me = j;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement