Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Program
- {
- enum identificator
- {
- Simple_Identificator,
- Operation_All,
- Identificator,
- Error
- }
- static bool symbol(char a)
- {
- return a >= 'A' && a <= 'Z';
- }
- static bool operation(char a)
- {
- return a == '+' || a == '-' || a == '/' || a == '*';
- }
- static identificator recursion(string a, int pos = 0)
- {
- if (a.Length != pos)
- {
- if (pos % 2 == 0) return symbol(a[pos]) ? recursion(a, pos + 1) : identificator.Error;
- return operation(a[pos]) ? recursion(a, pos + 1) : identificator.Error;
- }
- return identificator.Simple_Identificator;
- }
- static identificator check(string a)
- {
- if (a.Length == 1)
- {
- if (operation(a[0])) return identificator.Operation_All;
- if (symbol(a[0])) return identificator.Identificator;
- }
- if (a.Length % 2 == 0) return identificator.Error;
- return recursion(a);
- }
- public static void Main()
- {
- circle();
- }
- static void circle()
- {
- identificator ident = check(Console.ReadLine());
- if (ident == identificator.Simple_Identificator) Console.WriteLine("Statement");
- else if (ident == identificator.Identificator) Console.WriteLine("Identificator");
- else if (ident == identificator.Operation_All) Console.WriteLine("Operation");
- else Console.WriteLine("Invalid input");
- circle();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement