-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidString.cpp
More file actions
68 lines (56 loc) · 1018 Bytes
/
Copy pathvalidString.cpp
File metadata and controls
68 lines (56 loc) · 1018 Bytes
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
61
62
63
64
65
66
67
68
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
cin>>s;
int n = s.size();
cout<<n<<endl;
bool flag = true;
string temp ;
string discount;
for(int i=0;i<n-1;i++)
{
//cout<<s[i];
if(i<3 && !(s[i] >= 'A' && s[i]<='Z' ))
{
flag = false;
}
else if(i>2 && i<7)
{
temp.push_back(s[i]);
}
else if(i>6 && i<n)
{
discount.push_back(s[i]);
}
}
int k = stoi(temp);
int code = stoi(discount);
bool flag1 = false;
if(k>=1900 && k<=2019)
{
flag1 = true;
}
bool flag2 = false;
if(code == 10 || code == 20 || code == 50 || code == 100 ||code == 200 || code == 500 || code == 1000)
{
flag2 = true;
}
//cout<<flag<<" "<<flag1<<" "<<flag2;
if((n>=10 && n<= 12) &&(flag == true && flag1 == true && flag2 == true) && (s[n-1] >= 'A' && s[n-1] <= 'Z'))
{
cout<<true;
}
else
{
cout<<false;
}
/*
input->>
AVG190420T
output->
1
*/
return 0;
}