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;
- namespace domaxa7
- {
- class Program
- {
- static void Main()
- {
- StreamReader f = new StreamReader("C:\\Users\\Mezehe\\Desktop\\asd\\Vvod.txt"); //Создание переменной,которая считывает файл
- string text = f.ReadLine(); //Переменная с текстом входного файла
- string[] words; //Массив строк
- words = text.Split(default(string[]), StringSplitOptions.RemoveEmptyEntries);//Цикл,который идет по массиву и присваивает значение в переменную Word
- int count = 0;
- int tmp; //Переменная,считающая буквы "a" в словах
- foreach (var word in words) //
- {
- tmp = 0; //Отвечает за каждую букву "a"
- for (int n = 0; n < word.Length; ++n) //Цикл по длине строки считываемого файла
- if (word[n] == 'a')
- tmp++; //tmp = tmp+1;
- if (tmp == 3) count++;
- }
- StreamWriter f1 = new StreamWriter("C:\\Users\\Mezehe\\Desktop\\asd\\Vivod.txt"); //Создание переменной для записи в файл
- f1.Write("Kol = " + Convert.ToString(count)); //Запись в файл
- f1.Close(); //Закрытие файла
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement