Advertisement
jordan3900

Untitled

Aug 4th, 2017
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 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 _01.Files
  8. {
  9. class files
  10. {
  11. static void Main(string[] args)
  12. {
  13.  
  14. int n = int.Parse(Console.ReadLine());
  15. Dictionary<string, int> Data = new Dictionary<string, int>();
  16.  
  17. List<string> directories = new List<string>();
  18.  
  19. for (int i = 0; i < n; i++)
  20. {
  21. string line = Console.ReadLine();
  22. directories.Add(line);
  23. }
  24. string search = Console.ReadLine();
  25. string[] tokens = search.Split();
  26. string extension = tokens[0];
  27. string folder = tokens[2];
  28. foreach (var directory in directories)
  29. {
  30. string[] param = directory.Split('\\');
  31. string currentFolder = param[0];
  32. string currentExtension = param[param.Length - 1];
  33.  
  34. if (currentFolder.Contains(folder) && currentExtension.Contains(extension))
  35. {
  36. string[] token = currentExtension.Split(';');
  37. string name = token[0];
  38. int memory = int.Parse(token[1]);
  39.  
  40. if (!Data.ContainsKey(name))
  41. {
  42. Data[name] = 0;
  43. }
  44. Data[name] = memory;
  45. }
  46.  
  47. }
  48. if (Data.Count==0)
  49. {
  50. Console.WriteLine("No");
  51. return;
  52. }
  53. foreach (var item in Data.OrderByDescending(a=>a.Value).ThenBy(a=>a.Key))
  54. {
  55. Console.WriteLine($"{item.Key} - {item.Value} KB ");
  56. }
  57. }
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement