This commit is contained in:
Maryna Kravtsova 2020-10-21 14:54:51 +02:00
parent a2310e4d2d
commit 01620f4b61

View File

@ -68,16 +68,16 @@ int main(){
printf("%s", line);
int l = strlen(line);
int i, j = 0;
int i, j = -1;
char *a = calloc(l, sizeof(char));
char *b = calloc(l, sizeof(char));
for(i = 0; i < l; i++){
if(line[i] == '{' || line[i] == '(' || line[i] == '[' || line[i] == '<'){
push(line[i]);
j++;
a[j] = gettop();
b[j] = right_pair(a[j]);
j++;
}
if(line[i] == '}' || line[i] == ')' || line[i] == ']' || line[i] == '>'){
if(s.size == -1){
@ -86,7 +86,7 @@ int main(){
}
else if(!find_pair(gettop(), line[i])){
printf("Crossed bracket %c in %d, expected %c\n", line[i], i, b);
printf("Crossed bracket %c in %d, expected %c\n", line[i], i, b[j]);
return 0;
}
else{
@ -99,7 +99,7 @@ int main(){
int h;
while(begin < end){
h = b[begin];
b[begin] = b[--end];
b[begin++] = b[--end];
b[end] = h;
}