Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Forditok2gyak
- {
- class Program
- {
- static void Main(string[] args)
- {
- string allapot = "q0";
- string s = "-12651230";
- for (int i = 0; i < s.Length && allapot != "error"; i++)
- {
- Console.WriteLine("Állapot: " + allapot + " ||| Aktuális karakter: " + s[i].ToString());
- allapot = delta(allapot, s[i]);
- }
- Console.ReadKey();
- }
- static string delta(string allapot, char s)
- {
- switch (allapot + getAllapot(s))
- {
- case "q0-": return "q1";
- case "q0+": return "q1";
- case "q0N": return "q2";
- case "q1N": return "q2";
- case "q2N": return "q2";
- }
- return "error";
- }
- static string getAllapot(char str)
- {
- if (Char.IsDigit(str)) return "N";
- return str.ToString();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment