Advertisement
FLISEN

Untitled

Jan 29th, 2013
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.15 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4.     class Dictionary
  5.     {
  6.         static void Main()
  7.         {
  8.  
  9.             string dictionary = ".NET - platform for applications from Microsoft\n"
  10.                                    +"CLR - managed execution environment for .NET\n"
  11.                                     +"namespace - hierarchical organization of classes\n";
  12.            
  13.             string[] words = dictionary.Split('-', '\n');
  14.  
  15.             for (int i = 0; i < words.Length; i++)
  16.             {
  17.                 words[i] = words[i].Trim();
  18.             }
  19.  
  20.             Console.WriteLine("Which word you are looking for?");
  21.             string word = Console.ReadLine();
  22.             for (int i = 0; i < words.Length - 1; i += 2)
  23.             {
  24.                 if (word == words[i])
  25.                 {
  26.                     Console.WriteLine("The definition of \"{0}\" is:\n{1}", word, words[i + 1]);
  27.                     break;
  28.                 }
  29.                 else if (i == words.Length - 3)
  30.                 {
  31.                     Console.WriteLine("There is no such word!");
  32.                 }
  33.             }
  34.            
  35.         }
  36.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement