Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Threading;
- namespace testovaci
- {
- class MainClass
- {
- private static void Prochazej(int delka = 10, int pozice = 0, int citac = 0)
- {
- if (delka == Math.Abs (pozice)) {
- Console.WriteLine (pozice > 0 ? "Doma." : "V hospodě.");
- Console.WriteLine ("Počet kroků: {0}", citac);
- return;
- }
- var nahoda = new Random ();
- var prochazka = Enumerable.Range (1, 2 * delka-1).
- Select (i => i == (delka + pozice) ? '#' : '-').
- ToArray ();
- Thread.Sleep (50);
- Console.Clear ();
- Console.WriteLine (prochazka);
- pozice += nahoda.Next (1, 100) < 70 ? -1 : 1;
- Prochazej (pozice: pozice, citac: citac+1);
- }
- public static void Main (string[] args)
- {
- do
- {
- Prochazej();
- Console.WriteLine("Skončit stiskem Q, jinak znovu!");
- } while (Console.ReadKey().KeyChar != 'q');
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement