vencinachev

A7,8

Dec 2nd, 2020
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.54 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace GerryTutor
  8. {
  9.     class Program
  10.     {
  11.  
  12.         static List<double> Union(List<double> a, List<double> b)
  13.         {
  14.             List<double> result = new List<double>();
  15.             foreach (var item in a)
  16.             {
  17.                 if (!result.Contains(item))
  18.                 {
  19.                     result.Add(item);
  20.                 }
  21.             }
  22.             foreach (var item in b)
  23.             {
  24.                 if (!result.Contains(item))
  25.                 {
  26.                     result.Add(item);
  27.                 }
  28.             }
  29.             return result;
  30.         }
  31.         static List<int> NonRepeat(int[] arr)
  32.         {
  33.             HashSet<int> set = new HashSet<int>();
  34.             foreach (var item in arr)
  35.             {
  36.                 set.Add(item);
  37.             }
  38.             return set.ToList();
  39.         }
  40.         static void Main(string[] args)
  41.         {
  42.             Dictionary<char, int> d = new Dictionary<char, int>();
  43.             string text = Console.ReadLine();
  44.  
  45.             foreach (var ch in text)
  46.             {
  47.                 if (!d.ContainsKey(ch))
  48.                 {
  49.                     d.Add(ch, 1);
  50.                 }
  51.                 else
  52.                 {
  53.                     d[ch]++;
  54.                 }
  55.             }
  56.  
  57.             foreach (var item in d)
  58.             {
  59.                 Console.WriteLine($"{item.Key} -> {item.Value}");
  60.             }
  61.         }
  62.     }
  63. }
  64.  
Add Comment
Please, Sign In to add comment