Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Files
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- List<string> input = new List<string>();
- //READ DIRECTORIES
- for (int i = 0; i < n; i++){
- string inputLine = Console.ReadLine();
- input.Add(inputLine);
- }
- var inputCommand = Console.ReadLine();
- List<string> command = inputCommand.Split().ToList();
- string extension = command[0];
- string place = command[2];
- SortedDictionary<string, int> dictionary = new SortedDictionary<string, int>();
- bool hasSomething = false;
- for (int i = 0; i < input.Count; i++){
- //CHECK IF INPUT CONTAINS GIVEN DIRECTORY
- if (input[i].Contains(place)){
- List<string> splitted = new List<string>();
- splitted = input[i].Split('\\').ToList();
- for (int m = 0; m < splitted.Count; m++) {
- //CHECK IF INPUT CONTAINS GIVEN FILE EXTENTION
- if (splitted[m].Contains(extension)){
- hasSomething = true;
- List<string> files = splitted[m].Split(';').ToList();
- string file = files[0];
- int size = int.Parse(files[1]);
- //CHECK IF DICTIONARY CONTAINS KEY WITH DIFFERENT SIZE
- if (dictionary.ContainsKey(file) && !dictionary[file].Equals(size)) {
- dictionary[file] = size;
- }
- else {
- dictionary.Add(file, size);
- }
- }
- }
- }
- }
- //PRINT DICTIONARY IF IT CONTAINS SOMETHING
- if (hasSomething == true)
- {
- foreach (var pair in dictionary.OrderByDescending(key => key.Value))
- {
- Console.WriteLine("{0} - {1} KB", pair.Key, pair.Value);
- }
- }
- else
- {
- Console.WriteLine("No");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement