Advertisement
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 ConsoleApplication57
- {
- class Program
- {
- static public bool equals_sign_check(string str, int i)
- {
- if (str[i] == '=')
- {
- if (i - 1 >= 0)
- if (str[i - 1] == '=' || str[i - 1] == '<' || str[i - 1] == '>')
- return true;
- if (i + 1 < str.Length)
- if (str[i + 1] == '=')
- return true;
- return false;
- }
- else
- return false;
- }
- static public bool CountBrackets(string str)
- {
- int open = 0;
- int close = 0;
- for (int i = 0; i < str.Length; ++i)
- if (str[i] == '(')
- ++open;
- for (int i = 0; i < str.Length; ++i)
- if (str[i] == ')')
- ++close;
- if (open == close)
- return true;
- else
- return false;
- }
- static string alph = "qwertyuiopasdfghjklzxcvbnm";
- static string valid = "&|<>()";
- static public bool Validate(string str)
- {
- if (str == "")
- return false;
- for (int i = 0; i < str.Length; ++i)
- if (!((alph.Contains(str[i]) || valid.Contains(str[i]) || equals_sign_check(str, i)) && CountBrackets(str)))
- return false;
- return true;
- }
- static void Main(string[] args)
- {
- string line = Console.ReadLine();
- Console.WriteLine(Validate(line));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement