1
1
mirror of https://github.com/ParkMoonJ/KaoYan.git synced 2026-11-03 06:14:48 +08:00

Update 3.19

This commit is contained in:
ParkMoonJ
2021-04-09 09:52:15 +08:00
parent 54d5ef11e7
commit 061a9a8ba1
4 changed files with 22 additions and 11 deletions

View File

@@ -3,6 +3,10 @@
"iostream": "cpp",
"ostream": "cpp",
"*.rmd": "markdown",
"istream": "cpp"
"istream": "cpp",
"__locale": "cpp",
"__string": "cpp",
"string": "cpp",
"string_view": "cpp"
}
}

View File

@@ -376,6 +376,7 @@ bool bracket(char a) {
}
}
}
return true;
}
```

Binary file not shown.

View File

@@ -1,5 +1,6 @@
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
#define MAXSIZE 100
@@ -35,34 +36,39 @@ bool Pop(Stack &S, char x) {
return true;
}
bool Bracket(char *a) {
bool Bracket(char *a, int i) {
char x;
InitStack(S);
for (int i = 0; a[i]; i++) {
if (a[i] == '(' || a[i] == '[' || a[i] == '{') {
Push(S, a[i]);
} else if (a[i] == ']') {
for (int j = 0; j == i; j++)
{
if (a[j] == '(' || a[j] == '[' || a[j] == '{') {
Push(S, a[j]);
} else if (a[j] == ']') {
Pop(S, x);
if (x != '[') {
return false;
}
} else if (a[i] == ')') {
} else if (a[j] == ')') {
Pop(S, x);
if (x != '(') {
return false;
}
} else if (a[i] == '}') {
} else if (a[j] == '}') {
Pop(S, x);
if (x != '{') {
return false;
}
}
}
return true;
}
int main() {
int n;
cin.getline(a, MAXSIZE);
return Bracket(a);
int i = 0;
while ((a[i] = cin.get()) != '\n') {
++i;
}
cout << Bracket(a, i - 1);
return 0;
}