This commit is contained in:
Maryna Kravtsova 2020-10-21 14:46:30 +02:00
parent bef9c5185a
commit a2310e4d2d

View File

@ -19,11 +19,9 @@ void push(char ch){
exit(0);
}
char pop(){
if(s.size > 0){
void pop(){
if(s.size >= 0)
s.size--;
return (s.data[s.size]);
}
else
exit(0);
}
@ -75,19 +73,13 @@ int main(){
char *b = calloc(l, sizeof(char));
for(i = 0; i < l; i++){
//a[i] = gettop();
// b[i] = right_pair(a[i]);
if(line[i] == '{' || line[i] == '(' || line[i] == '[' || line[i] == '<'){
push(line[i]);
a[j] = gettop();
b[j] = right_pair(a[j]);
j++;
//printf("%c", b[i]);
}
if(line[i] == '}' || line[i] == ')' || line[i] == ']' || line[i] == '>'){
//a[i] = gettop();
//b[i] = right_pair(a[i]);
if(s.size == -1){
printf("Unexpected closing bracket %c in %d\n", line[i], i);
return 0;
@ -100,10 +92,17 @@ int main(){
else{
pop();
}
}
}
i = 0;
int begin = 0;
int end = strlen(b);
int h;
while(begin < end){
h = b[begin];
b[begin] = b[--end];
b[end] = h;
}
if(s.size == -1){
printf("All brackets OK\n");
}