Advertisement
AmidamaruZXC

Untitled

Oct 16th, 2020
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.96 KB | None | 0 0
  1. using System;
  2. using System.Text;
  3.  
  4. namespace Task12
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             string input = Console.ReadLine();
  11.             if (input != "")
  12.             {
  13.                 string[] ops = input.Split(',');
  14.                 ulong[] ans = new ulong[5];
  15.                 StringBuilder errors = new StringBuilder("");
  16.                 foreach (var op in ops)
  17.                 {
  18.                     if (op == "0" || op == "None")
  19.                         ans[0]++;
  20.                     else if (op == "1" || op == "First")
  21.                         ans[1]++;
  22.                     else if (op == "2" || op == "Second")
  23.                         ans[2]++;
  24.                     else if (op == "3" || op == "Third")
  25.                         ans[3]++;
  26.                     else if (op == "4" || op == "Fourth")
  27.                         ans[4]++;
  28.                     else
  29.                         errors.Append($"{op},");
  30.                 }
  31.                 if (!errors.ToString().Equals(""))
  32.                 {
  33.                     errors = errors.Remove(errors.Length - 1, 1);
  34.                     Console.WriteLine("Input data types:\n" +
  35.                         $"None(0)-{ans[0]}\n" +
  36.                         $"First(1)-{ans[1]}\n" +
  37.                         $"Second(2)-{ans[2]}\n" +
  38.                         $"Third(3)-{ans[3]}\n" +
  39.                         $"Fourth(4)-{ans[4]}\n" +
  40.                         $"Errors:\n" +
  41.                         $"Not valid input strings: {errors}");
  42.                 }
  43.                 else
  44.                     Console.WriteLine("Input data types:\n" +
  45.                        $"None(0)-{ans[0]}\n" +
  46.                        $"First(1)-{ans[1]}\n" +
  47.                        $"Second(2)-{ans[2]}\n" +
  48.                        $"Third(3)-{ans[3]}\n" +
  49.                        $"Fourth(4)-{ans[4]}");
  50.             }
  51.             else
  52.                 Console.WriteLine("No data");
  53.         }
  54.     }
  55. }
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement