Advertisement
Guest User

Untitled

a guest
Dec 14th, 2017
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.02 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. namespace EmptyProject
  5. {
  6.     public class Test
  7.     {
  8.         static void Main()
  9.         {
  10.             string input = Console.ReadLine();
  11.             string d = "";
  12.             string g = "";
  13.             string i = "";
  14.             bool e = false;
  15.             bool f = false;
  16.             Regex alphanumeric = new Regex("^[a-zA-Z0-9]*$");
  17.  
  18.             while (input != "Davai Emo")
  19.             {
  20.                 if (input.Substring(0, 5) == "Type:")
  21.                 {
  22.                     if (!e)
  23.                     {
  24.                         d = input.Substring(6);
  25.  
  26.                         if (d == "Normal" || d == "Warning" || d == "Danger")
  27.                         {
  28.                             e = true;
  29.                         }
  30.                     }
  31.                 }
  32.                 else if (input.Substring(0, 7) == "Source:")
  33.                 {
  34.                     if (!f)
  35.                     {
  36.                         if (e)
  37.                         {
  38.                             g = input.Substring(8);
  39.  
  40.                             if (alphanumeric.IsMatch(g))
  41.                             {
  42.                                 f = true;
  43.                             }
  44.                         }
  45.                     }
  46.                 }
  47.                 else if (input.Substring(0, 9) == "Forecast:")
  48.                 {
  49.                     i = input.Substring(10);
  50.  
  51.                     if (!i.Contains("!") && !i.Contains("?") && !i.Contains(".") && !i.Contains(","))
  52.                     {
  53.                         if (f)
  54.                         {
  55.                             Console.WriteLine("({0}) {1} ~ {2}", d, i, g);
  56.                             d = "";
  57.                             g = "";
  58.                             i = "";
  59.                             e = false;
  60.                             f = false;
  61.                         }
  62.                     }
  63.                 }
  64.  
  65.                 input = Console.ReadLine();
  66.             }
  67.         }
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement