10進制轉換與括號匹配算法:(如有BUG請指教,呵呵,一陣亂寫)
1:將十進制轉換成其他進制,包括2進制,8進制,16進制。
2:括號匹配算法,相應的括號進行匹配。
進制轉換算法與字符匹配算法
1 using System.Collections.Generic;
2 using System.Text;
3
4 public partial class DataStruct_ExchangeData : System.Web.UI.Page
5 {
6 protected void Page_Load(object sender, EventArgs e)
7 {
8
9 // ConvertIntToOther();
10 // ConvertionInt(654321,8);
11 MatchBreak("([])([][()])");
12 }
13 /// <summary>
14 /// compare the match of the string
15 /// </summary>
16 /// <param name="input">input string to compare</param>
17 private void MatchBreak(string input)
18 {
19 char[] charnum = input.ToCharArray();
20 Stack<string> stack = new Stack<string>();
21 foreach(char ch in charnum){
22 if(stack.Count==0){//數字為0的時候 壓入
23 stack.Push(ch.ToString());
24 }
25 else
26 {
27 &nbs