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;
- namespace ConsoleApplication14
- {
- class Program
- {
- static int max = 4;
- struct TRozsah
- {
- public string nazev;
- public char c1;
- public char c2;
- public int pocet;
- }
- static TRozsah[] rozsahy = new TRozsah[max];
- static void Analyzuj(string vstup)
- {
- for (int i = 0; i < max; i++) rozsahy[i].pocet=0;
- foreach (char c in vstup)
- {
- bool nalezeno = false;
- for (int i = 0; i < max; i++) if (c >= rozsahy[i].c1 && c <= rozsahy[i].c2)
- {
- rozsahy[i].pocet++;
- nalezeno = true;
- }
- if (!nalezeno) rozsahy[0].pocet++;
- }
- foreach (TRozsah r in rozsahy) Console.WriteLine("{0} {1}x", r.nazev,r.pocet);
- }
- static string ZadatText(string txt)
- {
- Console.WriteLine("Zadejte text");
- txt =Console.ReadLine();
- return txt;
- }
- static void Main(string[] args)
- {
- char volba = '0';
- string txt = "";
- rozsahy[0].nazev = "Ostatni"; rozsahy[0].c1 = ' '; rozsahy[0].c2 = ' ';
- rozsahy[1].nazev = "Mala pismena"; rozsahy[1].c1 = 'a'; rozsahy[1].c2 = 'z';
- rozsahy[2].nazev = "Velka pismena"; rozsahy[2].c1 = 'A'; rozsahy[2].c2 = 'Z';
- rozsahy[3].nazev = "Cislice"; rozsahy[3].c1 = '0'; rozsahy[3].c2 = '9';
- do
- {
- Console.Clear();
- if (volba == '1') txt = ZadatText(txt);
- if (volba == '2') Analyzuj(txt);
- Console.WriteLine("1..Zadat text\n2..Analyzovat text {0}\n------------\n9..Konec", txt);
- volba = Console.ReadKey().KeyChar;
- } while (volba != '0');
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement