Advertisement
AmidamaruZXC

Untitled

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