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 ConsoleApplication11
- {
- class Program
- {
- static void NactiText(ref string txt)
- {
- Console.WriteLine("Zadejte vstupni text:");
- txt = Console.ReadLine();
- }
- static bool JeCislice(char z)
- {
- return (z >= '0' && z <= '9');
- }
- static void Zpracuj(string txt)
- {
- char pred = '0';
- int pocetcisel = 0;
- for (int i = 0; i < txt.Length; i++)
- {
- if (JeCislice(pred) && (!(JeCislice(txt[i]))))
- pocetcisel++;
- pred = txt[i];
- }
- Console.WriteLine("Pocet celych cisel ve vete {0} je {1}", txt, pocetcisel);
- }
- static void Main(string[] args)
- {
- char volba = '9';
- string vstup = "";
- do
- {
- Console.Clear();
- if (volba == '1' || volba == '0') NactiText(ref vstup);
- if (volba == '2' || volba == '0') Zpracuj(vstup);
- Console.WriteLine("Program pocita pocet celych cisel v zadani. Napr. asdfsafd45.98asd je vysledek 2.\n\n1..Zadat vstupni text\n2..Zpracovat\n----------------\n9..Konec");
- volba = Console.ReadKey().KeyChar;
- } while (volba != '9');
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement