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.RegularExpressions;
- namespace DataTransfer
- {
- class Start
- {
- static void Main(string[] args)
- {
- string patttern = @"s\:([^\;]+)\;r\:([^\;]+)\;";
- string newPattern = @"s\:([^\;]+)\;r\:([^\;]+)\;m--""([A-Za-z ]+)""";
- int num = int.Parse(Console.ReadLine());
- int sum = 0;
- for (int i = 0; i < num; i++)
- {
- string inputStr = Console.ReadLine();
- MatchCollection match = Regex.Matches(inputStr, newPattern);
- foreach (Match item in match)
- {
- var senderP = "";
- var recieverP = "";
- var message = "";
- senderP = GetData(item.Groups[1].Value);
- recieverP = GetData(item.Groups[2].Value);
- message = GetData(item.Groups[3].Value);
- string allDigitsFrom = item.Groups[1].Value.ToString()+item.Groups[2].Value.ToString();
- sum += IsDigit(allDigitsFrom);
- Console.WriteLine($"{senderP} says \"{message}\" to {recieverP}");
- }
- }
- int total = sum;
- Console.WriteLine($"Total data transferred: {total}MB");
- }
- private static int IsDigit(string value1)
- {
- int sum = 0;
- string word = value1;
- foreach (var it in word)
- {
- if (Char.IsDigit(it))
- {
- sum += Convert.ToInt32(it.ToString());
- }
- }
- return sum;
- }
- private static string GetData(string word)
- {
- string info = "";
- foreach (var it in word)
- {
- if (Char.IsLetter(it) || it == ' ')
- {
- info += it;
- }
- }
- return info;
- }
- private static int Calculate(string senderP, string senderP1, string message)
- {
- int sum = 0;
- var all = (senderP + senderP1);
- for (int i = 0; i < all.Length; i++)
- {
- sum += Convert.ToInt32(all[i]);
- }
- return sum;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement