Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- using System.Linq;
- using System.Collections.Generic;
- namespace ExamPrepMeTubeStatistics
- {
- class Program
- {
- static void Main(string[] args)
- {
- Dictionary<string, int[]> videoStatistics =
- new Dictionary<string, int[]>();
- while (true)
- {
- string input = Console.ReadLine();
- if (input=="stats time")
- {
- break;
- }
- else
- {
- if (input.Contains("-"))
- {
- string[] videoStats = input.Split("-");
- string video = videoStats[0];
- int views = int.Parse(videoStats[1]);
- if (videoStatistics.ContainsKey(video) == false)
- {
- videoStatistics.Add(video, new int[2]);
- //videoStatistics[video][1] = views;
- }
- videoStatistics[video][1] += views;
- }
- else if (input.Contains(":"))
- {
- string[] videoStats = input.Split(":");
- string likesDislikes = videoStats[0];
- string video = videoStats[1];
- if (likesDislikes == "like")
- {
- if (videoStatistics.ContainsKey(video))
- {
- videoStatistics[video][0]++;
- }
- }
- else if (likesDislikes == "dislike")
- {
- if (videoStatistics.ContainsKey(video))
- {
- videoStatistics[video][0]--;
- }
- }
- }
- }
- }
- string sortCommand = Console.ReadLine();
- if (sortCommand=="by views")
- {
- foreach (var video in videoStatistics.OrderByDescending(x => x.Value[1]))
- {
- Console.WriteLine($"{video.Key} - {video.Value[1]} views - {video.Value[0]} likes");
- }
- }
- else
- {
- foreach (var video in videoStatistics.OrderByDescending(x => x.Value[0]))
- {
- Console.WriteLine($"{video.Key} - {video.Value[1]} views - {video.Value[0]} likes");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement