Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Text;
- namespace Dots
- {
- class Program
- {
- static void Main(string[] args)
- {
- //directory for example E:\Tekst.txt
- Console.WriteLine("Pleae, write the directroy of the .txt file you would like to check!\nExample:\"E:\\Tekst.txt\"");
- string directory = Console.ReadLine();
- string txt = File.ReadAllText(@$"{directory}");
- int comasCounter = 0;
- int dotsCounter = 0;
- int numbers = 0;
- bool lastCharIsDigit = false;
- foreach (char ch in txt)
- {
- if (ch == 44)
- {
- comasCounter++;
- lastCharIsDigit = false;
- }
- else if (ch == 46)
- {
- dotsCounter++;
- lastCharIsDigit = false;
- }else if (Char.IsDigit(ch) && lastCharIsDigit==false)
- {
- lastCharIsDigit = true;
- numbers++;
- }
- else if(Char.IsDigit(ch) && lastCharIsDigit == true)
- {
- lastCharIsDigit = true;
- }
- else
- {
- lastCharIsDigit = false;
- }
- }
- Console.WriteLine($"Count of dots: {dotsCounter}\nCount of comas: {comasCounter}\nNumbers in txt: {numbers}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement