Advertisement
Izpa

MIME

Oct 23rd, 2014
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.76 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.IO;
  4. using System.Text;
  5. using System.Collections;
  6. using System.Collections.Generic;
  7.  
  8. /**
  9.  * Auto-generated code below aims at helping you parse
  10.  * the standard input according to the problem statement.
  11.  **/
  12. class Solution
  13. {
  14.     static void Main(String[] args)
  15.     {
  16.         string[] inputs;
  17.         string[] fName;
  18.         int N = int.Parse(Console.ReadLine()); // Number of elements which make up the association table.
  19.         int Q = int.Parse(Console.ReadLine()); // Number Q of file names to be analyzed.
  20.         string[,] dataBase = new string [N,2];
  21.         int i;
  22.         for (i = 0; i < N; i++)
  23.         {
  24.             inputs = Console.ReadLine().Split(' ');
  25.             dataBase [i,0]= inputs[0]; // file extension
  26.             dataBase [i,1]= inputs[1]; // MIME type.
  27.         }
  28.         for (i = 0; i < Q; i++)
  29.         {
  30.             bool flag = true;
  31.             fName = Console.ReadLine().Split('.');
  32.             string fileType = fName[fName.Length-1];
  33.             for (int n = 0; n < N; n++) {
  34.                 if (fName.Length==1) break;
  35.                 int r = String.Compare (fileType, dataBase [n,0], true);
  36.                 if (r == 0) {
  37.                     Console.WriteLine (dataBase [n,1]);
  38.                     flag = false;
  39.                     break;
  40.                 }
  41.             }
  42.             if (flag == true) Console.WriteLine ("UNKNOWN");
  43.         }
  44.         Console.Error.WriteLine (i);
  45.         // Write an action using Console.WriteLine()
  46.         // To debug: Console.Error.WriteLine("Debug messages...");
  47.  
  48.         //Console.WriteLine("UNKNOWN"); // For each of the Q filenames, display on a line the corresponding MIME type. If there is no corresponding type, then display UNKNOWN.
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement