Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.13 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Text.RegularExpressions;
  6. using System.Threading.Tasks;
  7.  
  8. namespace dzwig
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             Boolean obrot = false, czy_liczba=false;
  15.             int kat = 1;
  16.             String pobrany_tekst = "Obróć się o 30 stopni w prawo";
  17.  
  18.             Char delimiter = ' ';
  19.             String[] substrings = pobrany_tekst.Split(delimiter);
  20.             foreach (var substring in substrings)
  21.             {
  22.                 if (substring == "Obróć")
  23.                 {
  24.                 obrot = true;
  25.                 }
  26.                 //int.TryParse(substring, out kat);
  27.                 if (czy_liczba = Regex.IsMatch(substring, @"^\d+$"))
  28.                 {
  29.                     int.TryParse(substring, out kat);
  30.                     Console.WriteLine(kat);
  31.                 }
  32.              }
  33.             if (obrot) Console.WriteLine("Występuje słowo obrót");
  34.             //Console.WriteLine(kat);
  35.             System.Console.Read();
  36.  
  37.  
  38.  
  39.            
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement