-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMIME_Type.cs
More file actions
37 lines (33 loc) · 1.24 KB
/
MIME_Type.cs
File metadata and controls
37 lines (33 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp6
{
class Program
{
static void Main(string[] args)
{
int N = int.Parse(Console.ReadLine()); // Number of elements which make up the association table.
int Q = int.Parse(Console.ReadLine()); // Number Q of file names to be analyzed.
Dictionary<string, string> mimes = new Dictionary<string, string>();
for (int i = 0; i < N; i++)
{
string[] inputs = Console.ReadLine().Split(' ');
string EXT = inputs[0].ToLower(); // file extension
string MT = inputs[1]; // MIME type.
mimes.Add(EXT, MT);
}
for (int i = 0; i < Q; i++)
{
string FNAME = Console.ReadLine(); // One file name per line.
string ext = FNAME.Substring(FNAME.LastIndexOf('.') + 1).ToLower();
if (FNAME.Contains(".") && mimes.ContainsKey(ext))
Console.WriteLine(mimes[ext]);
else
Console.WriteLine("UNKNOWN");
}
}
}
}