Advertisement
dezsoo

Untitled

May 10th, 2021
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.39 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3.  
  4. namespace calc
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             string fajl = File.ReadAllText("mytext.txt");
  11.             int countA = 0;
  12.             int countNeve = 0;
  13.             int countMgh = 0;
  14.             string[] mghk = { "a", "á", "e", "é", "i", "í", "o", "ó", "ö", "ő", "u", "ú", "ü", "ű" };
  15.             for (int i = 0; i < fajl.Length; i++)
  16.             {
  17.                 if (fajl[i] == 'a' || fajl[i] == 'A')
  18.                 {
  19.                     countA++;
  20.                 }
  21.                 if (i == 0)
  22.                 {
  23.                     if (fajl[i + 1] == Convert.ToChar(" "))
  24.                     {
  25.                         countNeve++;
  26.                     }
  27.                 }
  28.                 else
  29.                 {
  30.                     if (fajl[i - 1] == Convert.ToChar(" ") && fajl[i + 1] == Convert.ToChar(" ")) { countNeve++; }
  31.                 }
  32.  
  33.                 for (int j = 0; j < mghk.Length; j++)
  34.                 {
  35.                     if (fajl[i] == Convert.ToChar(mghk[j]) || fajl[i] == Convert.ToChar(mghk[j].ToUpper())) { countMgh++; }
  36.                 }
  37.             }
  38.             Console.WriteLine(countA + " db a");
  39.             Console.WriteLine(countNeve + " db névelő a");
  40.             Console.WriteLine(countMgh + " db mgh");
  41.             Console.ReadKey();
  42.         }
  43.     }
  44. }
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement