Advertisement
ntamas

kő-papír-olló

Apr 3rd, 2014
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.34 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication1
  7. {
  8.   class Program
  9.   {
  10.     enum targyak
  11.     {
  12.       ko,
  13.       papir,
  14.       ollo
  15.     }
  16.     static void Main(string[] args)
  17.     {
  18.       int tipp1, tipp2;
  19.       int[] szamok = new int[3];
  20.       Random vel = new Random();
  21.       szamok[0] = (int)targyak.ko + 1;
  22.       szamok[1] = (int)targyak.papir + 1;
  23.       szamok[2] = (int)targyak.ollo + 1;
  24.       do
  25.       {
  26.         Console.WriteLine("Jelmagyarázat: {0} - kő, {1} - papír, {2} - olló", szamok[0], szamok[1], szamok[2]);
  27.         Console.Write("Első játékos tippje: 1-3-ig: ");
  28.         tipp1 = Convert.ToInt32(Console.ReadLine());
  29.         tipp2 = szamok[vel.Next(0, 3)];
  30.         Console.Write("Második játékos tippje: 1-3-ig: {0} \n", tipp2);
  31.       } while (tipp1 == tipp2);
  32.       if ((tipp1 == szamok[2] && tipp2 == szamok[1]) || (tipp1 == szamok[1] && tipp2 == szamok[0]) || (tipp1 == szamok[0] && tipp2 == szamok[2]))
  33.       {
  34.         Console.WriteLine("Az első játékos nyert.");
  35.       }
  36.       else if ((tipp1 == szamok[2] && tipp2 == szamok[0]) || (tipp1 == szamok[1] && tipp2 == szamok[2]) || (tipp1 == szamok[0] && tipp2 == szamok[1]))
  37.       {
  38.         Console.WriteLine("A második játékos nyert.");
  39.       }
  40.       Console.ReadKey();
  41.     }
  42.   }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement