Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.85 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.IO;
  6. using System.Threading.Tasks;
  7.  
  8. namespace ConsoleApp14
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             const string CFd = "..\\..\\tekstas.txt";
  15.             const string CFr = "..\\..\\rez.txt";
  16.             char[] skyrikliai = { ' ', '.' };
  17.             string sk = new string(skyrikliai);
  18.             skaitoraso(CFd, CFr,sk);
  19.             //string[] ilgiausias = new string[100];
  20.            
  21.             string zodis="";
  22.             int me = -1;
  23.             RastiZTekste(CFd, sk, out zodis, ref me);
  24.             if (me > 0)
  25.             {
  26.                 Console.WriteLine("ilgzod:{0}", zodis);
  27.             }
  28.             //else Console.WriteLine("nera");
  29.  
  30.         }
  31.  
  32.         static void skaitoraso(string fv, string fr, string sk)
  33.         {
  34.             int kiekis = 0;
  35.             using (StreamReader reader = new StreamReader(fv, Encoding.GetEncoding(1257)))
  36.             {
  37.                 string line;
  38.                 while ((line = reader.ReadLine()) != null)
  39.                 {
  40.                     //Balsiusk(line);
  41.                     //Console.WriteLine(Balsiusk(line));
  42.                     //Console.WriteLine(RastiZodiEil(line, sk));
  43.  
  44.                 }
  45.  
  46.             }
  47.         }
  48.  
  49.         static int Balsiusk(string e)
  50.         {
  51.             int kiek = 0;
  52.             char[] balses = { 'a', 'o', 'u', 'i', 'e', 'y' };
  53.             for (int i = 0; i < balses.Length; i++)
  54.             {
  55.                 if (e.IndexOf(balses[i]) >= 0)
  56.                     kiek++;
  57.             }
  58.             return kiek;
  59.         }
  60.  
  61.  
  62.         static string RastiZodiEil(string e, string sk)
  63.         {
  64.             //char[] mas = sk.ToCharArray();
  65.             string ilgzod = "";
  66.             string tuscias = "";
  67.             string[] parts = e.Split(sk.ToArray(), StringSplitOptions.RemoveEmptyEntries);
  68.             foreach (string zodis in parts)
  69.                 if (zodis.Length > ilgzod.Length && Balsiusk(e) >= 3)
  70.                     ilgzod = zodis;
  71.                 else return tuscias;
  72.             return ilgzod;
  73.            
  74.  
  75.         }
  76.  
  77.         static void RastiZTekste(string fv, string sk, out string zod, ref int me)
  78.         {
  79.            
  80.             string[] lines = File.ReadAllLines(fv, Encoding.GetEncoding(1257));
  81.             zod = "";
  82.             me = -1;
  83.             int ilgis = 0;
  84.             int j = 0;
  85.             foreach (string line in lines)
  86.             {
  87.                 if (RastiZodiEil(line, sk).Length > 0 && RastiZodiEil(line, sk).Length > zod.Length)
  88.                 {
  89.                     zod = RastiZodiEil(line, sk);
  90.                     ilgis = RastiZodiEil(line, sk).Length;
  91.                     j++;
  92.                 }
  93.                 me = j;
  94.             }
  95.         }
  96.     }
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement