資料結構實驗之棧與佇列四 括號匹配

2021-08-29 01:14:15 字數 1026 閱讀 4546

problem description

給你一串字元,不超過50個字元,可能包括括號、數字、字母、標點符號、空格,你的任務是檢查這一串字元中的( ) ,[ ],是否匹配。

input

輸入資料有多組,處理到檔案結束。

output

如果匹配就輸出「yes」,不匹配輸出「no」

sample input

sin(20+10)

]sample output

yesno

不能先輸入右括號

#include

#include

#include

#include

#include

#define inf 0x3f3f3f3f

#define maxn 100

using namespace std;

char a[

110]

;typedef

struct

stack;

void

creat

(stack *s)

void

push

(stack *s,

char x)

char

pop(stack *s)

intempty

(stack *s)

intmain()

else flag=1;

}else

if(a[i]

=='}'

)else flag=1;

}else

if(a[i]

==']'

)else flag=1;

}}if(flag||

!empty

(&s)

)printf

("no\n");

else

printf

("yes\n");

}return0;

}

資料結構實驗之棧與佇列四 括號匹配

time limit 1000ms memory limit 65536kb submit statistic problem description 給你一串字元,不超過50個字元,可能包括括號 數字 字母 標點符號 空格,你的任務是檢查這一串字元中的 是否匹配。input 輸入資料有多組,處理到...

資料結構實驗之棧與佇列四 括號匹配

problem description 給你一串字元,不超過50個字元,可能包括括號 數字 字母 標點符號 空格,你的任務是檢查這一串字元中的 是否匹配。input 輸入資料有多組,處理到檔案結束。output 如果匹配就輸出 yes 不匹配輸出 no example input sin 20 10...

資料結構實驗之棧與佇列四 括號匹配

problem description 給你一串字元,不超過50個字元,可能包括括號 數字 字母 標點符號 空格,你的任務是檢查這一串字元中的 是否匹配。input 輸入資料有多組,處理到檔案結束。output 如果匹配就輸出 yes 不匹配輸出 no example input sin 20 10...