forked from PEC-CSS/Open-Source
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCheckAB.cpp
More file actions
37 lines (34 loc) · 693 Bytes
/
CheckAB.cpp
File metadata and controls
37 lines (34 loc) · 693 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
#include <iostream>
using namespace std;
bool checkAB(char input[]) {
if(input[0]=='a')
{
if(input[1]=='\0')
return true;
else if(input[1]=='a')
return checkAB(input+1);
else if(input[1]=='b'&&input[2]=='b')
{
if(input[3]=='\0')
return true;
else if(input[3]=='a')
return checkAB(input+3);
else
return false;
}
else
return false;
}
else
return false;
}
int main() {
char input[100];
bool ans;
cin >> input;
ans=checkAB(input);
if(ans)
cout<< "true" << endl;
else
cout<< "false" << endl;
}