Guest User

Untitled

a guest
Nov 3rd, 2017
137
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Text.RegularExpressions;
  6. using System.Threading.Tasks;
  7.  
  8. class _04_Files
  9. {
  10. static void Main(string[] args)
  11. {
  12. var n = int.Parse(Console.ReadLine());
  13.  
  14. List<string> fullPaths = new List<string>();
  15.  
  16.  
  17. for (int i = 1; i <= n; i++)
  18. {
  19. fullPaths.Add(Console.ReadLine());
  20. }
  21. string filter = Console.ReadLine();
  22.  
  23.  
  24. var filterParts = filter
  25. .Split(new string[] { " in " },
  26. StringSplitOptions.RemoveEmptyEntries);
  27. var filterExtension = filterParts[0];
  28. var filterRoot = filterParts[1];
  29.  
  30. DesignateNeededItems(fullPaths, filterExtension, filterRoot);
  31.  
  32. }
  33. public static void DesignateNeededItems(List<string> fullPaths,
  34. string ext, string root)
  35. {
  36.  
  37. SortedDictionary<string, decimal> result =
  38. new SortedDictionary<string, decimal>();
  39.  
  40. for (int i = 0; i < fullPaths.Count; i++)
  41. {
  42. var folders = fullPaths[i]
  43. .Split('\\').ToList();
  44. var fileAndSize = folders[folders.Count - 1]
  45. .Split(';').ToList();
  46.  
  47. string start = folders[0];
  48.  
  49. string fileName = fileAndSize[0];
  50. decimal size = decimal.Parse(fileAndSize[1]);
  51.  
  52. if (root==start&&fileName.Contains("."+ext))
  53. {
  54. result.Add(fileName, size);
  55.  
  56. }
  57. }
  58. var sortedDict = from entry in result orderby entry.Value ascending select entry;
  59. if (result.Count == 0)
  60. {
  61. Console.WriteLine("No");
  62. return;
  63. }
  64. else
  65. {
  66. foreach (var item in sortedDict)
  67. {
  68.  
  69. Console.WriteLine($"{item.Key} - {item.Value} KB");
  70. }
  71. }
  72. }
  73. }
RAW Paste Data