-
Notifications
You must be signed in to change notification settings - Fork 0
/
WYJNLP01.cpp
40 lines (35 loc) · 1002 Bytes
/
WYJNLP01.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
#include <iostream>
#include <CString>
#define MAX_LENGRH 100
using namespace std;
int matrix[][4] = {{-1, 1, 0, -1}, {1, -1, -1, 0}, {0, -1, -1, 1}, {-1, 0, 1, -1}};
int main() {
char s[MAX_LENGRH];
int flag;
cout << "请输入被检测字符串:...\n";
while(scanf("%s", &s) != EOF) {
//cout << s << strlen(s) << endl;
int lie = 0;
for(int i = 0; i < strlen(s); i++) {
flag = 0;
for(int j = 0; j < 4; j++) {
if((s[i] - '0') == matrix[j][lie]) {
lie = j;
flag = 1;
break;
}
}
if(!flag)
break;
}
if(!flag) cout << "字符串中的字符不在输入字符集中!\n";
else {
if(lie)
cout << "字符串不可以被有限自动机接收!\n";
else
cout << "字符串可以被有限自动机接收!\n";
}
}
//cout << matrix[1][2] << endl;
return 0;
}