-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask2.cpp
More file actions
51 lines (38 loc) · 678 Bytes
/
Task2.cpp
File metadata and controls
51 lines (38 loc) · 678 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
#include <iostream>
using namespace std;
bool check(char *p) {
if (*p != 'a'){
return false;
p++;
}
if (*p == 'a') {
while (*p == 'a'){
p++;
}
}
else if (*p == 'b') {
while (*p == 'b'){
p++;
}
}
if (*p != 'b'){
return false;
}
p++;
while (*p == 'a') {
p++;
}
return (*p == '\0');
}
int main() {
char s[100];
cout << "Enter a string: ";
cin >> s;
cout << "Checking string..." << endl;
if (check(s)) {
cout << "Accepted" << endl;
} else {
cout << "Rejected" << endl;
}
return 0;
}