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.Threading.Tasks;
- using System.IO;
- namespace ConsoleApplication4
- {
- class Program
- {
- static void Main(string[] args)
- {
- string Eil = "Labas mano 2vardas lukasssss.";
- Console.WriteLine("Skirtingos balses: {0}", SkirtingosBalses(Eil));
- char[] Sk = { ' ', ',', '.' };
- string Skyrikliai = new string(Sk);
- Console.WriteLine("Ilgiausias zodis: {0}", RastiIlgiausiaZodis(Eil, Skyrikliai));
- }
- static int SkirtingosBalses(string eilute)
- {
- char[] Balses = {'a','b','m'};
- int kiek = 0;
- for (int i = 0; i < Balses.Length; i++)
- if (eilute.IndexOf(Balses[i]) >= 0)
- kiek++;
- return kiek;
- }
- static string RastiIlgiausiaZodis(string eilute, string skyrikliai)
- {
- char[] Sk = {' ', ',', '.'};
- Sk = skyrikliai.ToCharArray();
- string[] Parts = eilute.Split(Sk, StringSplitOptions.RemoveEmptyEntries);
- string Ilgiausia = "";
- foreach (string Zodis in Parts)
- {
- if (SkirtingosBalses(eilute) >= 3)
- {
- if (Zodis.Length > Ilgiausia.Length)
- {
- Ilgiausia = Zodis;
- }
- }
- }
- return Ilgiausia;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement