-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinteger-regular-expression.cpp
60 lines (55 loc) · 1.05 KB
/
integer-regular-expression.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
bool isVariable(string x)
{
bool mark = true;
if ((tolower(x[0]) < 'i') or (tolower(x[0]) > 'n'))
{
mark = false;
}
for (int i = 1; x[i]; i++)
{
if (tolower(x[i]) >= 'a' and tolower(x[i]) <= 'z')
{
continue;
}
else if (x[i] >= '0' and x[i] <= '9')
{
continue;
}
else
{
mark = false;
break;
}
}
return mark;
}
bool isInt(string x)
{
bool mark = true;
for (int i = 0; x[i]; i++)
{
if (isdigit(x[i])) continue;
else
{
mark = false;
break;
}
}
return mark;
}
int main()
{
string word;
cin >> word;
if (isVariable(word))
{
cout << "Integer Variable";
}
else if (word.size() <= 4 and isInt(word)) cout << "ShortInt Number";
else if (isInt(word)) cout << "LongInt Number";
else cout << "Invalid Input or Undefined";
return 0;
}