Advertisement
Guest User

Untitled

a guest
Feb 25th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.98 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 _04.ArrayHistogram
  8. {
  9.     class ArrayHistogram
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var input = Console.ReadLine().Split().ToArray();
  14.  
  15.             var words = new List<string>();
  16.             var occurrencesCount = new List<int>();
  17.             int count = 1;
  18.             for (int i = 0; i < input.Length; i++)
  19.             {
  20.                 if (!words.Contains(input[i]))
  21.                 {
  22.                     words.Add(input[i]);
  23.                     occurrencesCount.Insert(i,count);
  24.                 }
  25.                 else if (words.Contains(input[i]))
  26.                 {
  27.                     occurrencesCount.Insert(//??, count++);
  28.                 }
  29.  
  30.             }
  31.  
  32.             Console.WriteLine(string.Join(" ", words));
  33.             Console.WriteLine(string.Join(" ", occurrencesCount));
  34.         }      
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement