Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- namespace calc
- {
- class Program
- {
- static void Main(string[] args)
- {
- string fajl = File.ReadAllText("mytext.txt");
- int countA = 0;
- int countNeve = 0;
- int countMgh = 0;
- string[] mghk = { "a", "á", "e", "é", "i", "í", "o", "ó", "ö", "ő", "u", "ú", "ü", "ű" };
- for (int i = 0; i < fajl.Length; i++)
- {
- if (fajl[i] == 'a' || fajl[i] == 'A')
- {
- countA++;
- }
- if (i == 0)
- {
- if (fajl[i + 1] == Convert.ToChar(" "))
- {
- countNeve++;
- }
- }
- else
- {
- if (fajl[i - 1] == Convert.ToChar(" ") && fajl[i + 1] == Convert.ToChar(" ")) { countNeve++; }
- }
- for (int j = 0; j < mghk.Length; j++)
- {
- if (fajl[i] == Convert.ToChar(mghk[j]) || fajl[i] == Convert.ToChar(mghk[j].ToUpper())) { countMgh++; }
- }
- }
- Console.WriteLine(countA + " db a");
- Console.WriteLine(countNeve + " db névelő a");
- Console.WriteLine(countMgh + " db mgh");
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement