SDUT 2134 資料結構實驗之棧四 括號匹配

2022-05-17 06:39:13 字數 895 閱讀 2468

n圓括號和方括號,其巢狀的順序隨意。如([]())或[([ ][ ])]等為正確的匹配;而[( ])或([ ]( )或 ( ( ) ) )均為錯誤的匹配。

這裡只介紹了()【】其實加上{}是一樣的性質 看**

1 #include

2 #include

3int sw(char str)

4 ')

21return

7;22

else

23return

0;24 }

25int push(int top,char str,char stack)

26 30

int main()

31 52

if(sw(str[i])+sw(stack[top--]) == 10)

53 flag = 1;

54else

55 flag = 0;

56 }

57if(flag == 0)

58break;

59 }

6061

if(flag == 1&&top == 0)

62 printf("

yes\n

");63

else

64 printf("

no\n

");65 }

66return

0 ;67 }

SDUT2134資料結構實驗之棧四 括號匹配(棧)

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

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

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

sdut資料結構上機實驗之順序查詢

資料結構上機實驗之順序查詢 time limit 1000ms memory limit 65536k 在乙個的序列裡,查詢元素是否存在,若存在輸出yes,不存在輸出no.本題多組資料,首先輸入乙個數字n,然後輸入n n 1000 個數,然後再輸入乙個查詢數字。若存在輸出yes,不存在輸出no.4 ...