NMDanny

Strings T1

Jan 21st, 2013
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.12 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace _21_1_String_1
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             int End = 0, Know = 0, i = 0;
  13.             string[] Chosen = { "anny", "banny", "canny", "danny", "eanny" };
  14.             Console.WriteLine("Type the contestant name");
  15.             string Contestant = Console.ReadLine().ToLower();
  16.             while (End != 1)
  17.             {
  18.                 if (i != Chosen.Length + 1)
  19.                 {
  20.                     if (Chosen[i] == Contestant)
  21.                     {
  22.                         Know = i + 1;
  23.                         Console.WriteLine("{0} Won, he knew this after {1} player names were read", Contestant, Know);
  24.                         End = 1;
  25.                     }
  26.                     else if (Contestant.CompareTo(Chosen[i]) == -1)
  27.                     {
  28.                         Know = i + 1;
  29.                         Console.WriteLine("{0} Lost, he knew this after {1} player names were read", Contestant, Know);
  30.                         End = 1;
  31.                     }
  32.                     else if (i == Chosen.Length-1)
  33.                     {
  34.                         Console.WriteLine("{0} Lost, he knew this after {1} player names were read", Contestant, Chosen.Length);
  35.                         break;
  36.                     }
  37.                     else
  38.                     {
  39.                         ++i;
  40.                     }
  41.                 }
  42.             }
  43.         }
  44.     }
  45. }
  46. /*
  47.  * בסיום בחינת הקבלה למקהלת הזמר העירונית יוצא הבוחן הראשי וקורא את שמות המועמדים עפ סדר האלף בת
  48.  * מי ששומע את שמו יודע שהתקבל, ומועמד ששמו לא נקרא ושמע שם אחר המופיע בסדר האב יודע כי לא התקבל ללהקה
  49.  * קלוט את שם המועמד ורשימת שמות שבחר הבוחן
  50.  * פלוט אם המועמד התקבל ומספר הרשימה שהיה עליו לשמוע לפני שהגיע למסקנה אם התקבל או לא
  51.  */
Advertisement
Add Comment
Please, Sign In to add comment