Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- static void Main(string[] args)
- {
- string line = "start";
- int count = 0;
- List<string> linebox = new List<string>();
- List<string> wordbox = new List<string>();
- try
- {
- StreamReader sr = new StreamReader(@"C:\Users\Home\source\repos\ConsoleApp1\lul.txt");
- while(line != null)
- {
- line = sr.ReadLine();
- if(line == null)
- {
- continue;
- }
- else
- {
- linebox.Add(line);
- }
- }
- sr.Close();
- }
- catch(Exception ex)
- {
- Console.WriteLine(ex.Message);
- }
- foreach(string s in linebox)
- {
- wordbox.AddRange(s.Split(' '));
- }
- foreach(string s in wordbox)
- {
- if(s.Length <= 4)
- {
- count++;
- }
- }
- Console.WriteLine("Количество слов, в которых не больше 4 букв: {0}", count);
- Console.ReadLine();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement