14.3 正则表达式应用
2010-04-18 20:30
225 查看
14.3.4 查找嵌套标记
代码
Sub PlayPoker()
PlayPokerHand("StraightFlush", "1H", "2H", "3H", "4H", "5H")
PlayPokerHand("StraightFlush", "3H", "4H", "5H", "6H", "7H")
PlayPokerHand("StraightFlush", "6C", "7C", "8C", "9C", "TC")
PlayPokerHand("StraightFlush", "7S", "8S", "9S", "TS", "JS")
PlayPokerHand("StraightFlush", "8S", "9S", "TS", "JS", "QS")
PlayPokerHand("StraightFlush", "TD", "JD", "QD", "KD", "1D")
PlayPokerHand("Flush", "8S", "JS", "QS", "KS", "1S")
PlayPokerHand("Flush", "7H", "8H", "9H", "TH", "KH")
PlayPokerHand("Flush", "8C", "9C", "TC", "QC", "KC")
PlayPokerHand("FourOfAKind", "8C", "9D", "8D", "8H", "8S")
PlayPokerHand("FourOfAKind", "TS", "TC", "QD", "TD", "TH")
PlayPokerHand("FourOfAKind", "1C", "1S", "8S", "1H", "1D")
PlayPokerHand("FullHouse", "1C", "1D", "8C", "1D", "8S")
PlayPokerHand("FullHouse", "9C", "9S", "8D", "8S", "9H")
PlayPokerHand("FullHouse", "QC", "TD", "QD", "TS", "QS")
PlayPokerHand("Straight", "3S", "7S", "5S", "4S", "6D")
PlayPokerHand("Straight", "6D", "7S", "8H", "9H", "TD")
PlayPokerHand("Straight", "7S", "8D", "9D", "TH", "JC")
PlayPokerHand("Straight", "TC", "JS", "QS", "KS", "1S")
PlayPokerHand("ThreeOfAKind", "9C", "9S", "8H", "TD", "9D")
PlayPokerHand("ThreeOfAKind", "TC", "TS", "7S", "TH", "1D")
PlayPokerHand("ThreeOfAKind", "TC", "TS", "8S", "TH", "KH")
PlayPokerHand("TwoPairs", "1C", "1F", "8F", "DP", "8Q")
PlayPokerHand("TwoPairs", "9C", "KF", "8F", "8P", "9Q")
PlayPokerHand("TwoPairs", "1C", "DF", "QF", "DP", "QQ")
PlayPokerHand("OnePair", "1C", "1H", "KH", "TS", "8S")
PlayPokerHand("OnePair", "9C", "KH", "QH", "8S", "9D")
PlayPokerHand("OnePair", "1S", "TS", "QC", "8C", "QC")
PlayPokerHand("HighCard", "1C", "QC", "KC", "TD", "8D")
PlayPokerHand("HighCard", "TC", "KC", "QD", "8D", "9H")
PlayPokerHand("HighCard", "1C", "TC", "KD", "8D", "QH")
PlayPokerHand("HighCard", "8D", "QD", "TD", "9D", "KH")
End Sub
Private Sub PlayPokerHand(ByVal expectedScore As String, ByVal ParamArray cards() As String)
Dim score As String = PokerGame.EvalPokerScore2(cards)
Console.WriteLine("{0} {1} {2} {3} {4} => {5}", cards(0), cards(1), cards(2), cards(3), cards(4), score)
If score <> expectedScore Then Console.WriteLine(" WRONG! (expected {0})", expectedScore)
End Sub
代码
Sub PlayPoker()
PlayPokerHand("StraightFlush", "1H", "2H", "3H", "4H", "5H")
PlayPokerHand("StraightFlush", "3H", "4H", "5H", "6H", "7H")
PlayPokerHand("StraightFlush", "6C", "7C", "8C", "9C", "TC")
PlayPokerHand("StraightFlush", "7S", "8S", "9S", "TS", "JS")
PlayPokerHand("StraightFlush", "8S", "9S", "TS", "JS", "QS")
PlayPokerHand("StraightFlush", "TD", "JD", "QD", "KD", "1D")
PlayPokerHand("Flush", "8S", "JS", "QS", "KS", "1S")
PlayPokerHand("Flush", "7H", "8H", "9H", "TH", "KH")
PlayPokerHand("Flush", "8C", "9C", "TC", "QC", "KC")
PlayPokerHand("FourOfAKind", "8C", "9D", "8D", "8H", "8S")
PlayPokerHand("FourOfAKind", "TS", "TC", "QD", "TD", "TH")
PlayPokerHand("FourOfAKind", "1C", "1S", "8S", "1H", "1D")
PlayPokerHand("FullHouse", "1C", "1D", "8C", "1D", "8S")
PlayPokerHand("FullHouse", "9C", "9S", "8D", "8S", "9H")
PlayPokerHand("FullHouse", "QC", "TD", "QD", "TS", "QS")
PlayPokerHand("Straight", "3S", "7S", "5S", "4S", "6D")
PlayPokerHand("Straight", "6D", "7S", "8H", "9H", "TD")
PlayPokerHand("Straight", "7S", "8D", "9D", "TH", "JC")
PlayPokerHand("Straight", "TC", "JS", "QS", "KS", "1S")
PlayPokerHand("ThreeOfAKind", "9C", "9S", "8H", "TD", "9D")
PlayPokerHand("ThreeOfAKind", "TC", "TS", "7S", "TH", "1D")
PlayPokerHand("ThreeOfAKind", "TC", "TS", "8S", "TH", "KH")
PlayPokerHand("TwoPairs", "1C", "1F", "8F", "DP", "8Q")
PlayPokerHand("TwoPairs", "9C", "KF", "8F", "8P", "9Q")
PlayPokerHand("TwoPairs", "1C", "DF", "QF", "DP", "QQ")
PlayPokerHand("OnePair", "1C", "1H", "KH", "TS", "8S")
PlayPokerHand("OnePair", "9C", "KH", "QH", "8S", "9D")
PlayPokerHand("OnePair", "1S", "TS", "QC", "8C", "QC")
PlayPokerHand("HighCard", "1C", "QC", "KC", "TD", "8D")
PlayPokerHand("HighCard", "TC", "KC", "QD", "8D", "9H")
PlayPokerHand("HighCard", "1C", "TC", "KD", "8D", "QH")
PlayPokerHand("HighCard", "8D", "QD", "TD", "9D", "KH")
End Sub
Private Sub PlayPokerHand(ByVal expectedScore As String, ByVal ParamArray cards() As String)
Dim score As String = PokerGame.EvalPokerScore2(cards)
Console.WriteLine("{0} {1} {2} {3} {4} => {5}", cards(0), cards(1), cards(2), cards(3), cards(4), score)
If score <> expectedScore Then Console.WriteLine(" WRONG! (expected {0})", expectedScore)
End Sub
相关文章推荐
- 正则表达式,java,js简单应用
- ASP中应用正则表达式
- HDOJ 2206 IP的计算(正则表达式的应用)
- 正则表达式在UBB论坛中的应用
- 正则表达式的简单应用
- JAVA中正则表达式的应用 (一)
- 我的php学习笔记(三十五)PHP中正则表达式学习及应用(三)
- 正则表达式和通配符的应用
- JAVA中正则表达式的应用-java.util.regex
- Java实用方法整理(二)——正则表达式的应用
- 正则表达式基础及高级应用
- JAVA中正则表达式的应用 (二)
- 正则表达式学习与应用及JAVA中相关函数
- [.net 面向对象程序设计进阶] (3) 正则表达式 (二) 高级应用
- JAVA中正则表达式的应用
- java正则表达式应用
- editplus查找替换的正则表达式应用
- asp.net 正则表达式的应用
- notepad++ 正则表达式 应用案例1
- JavaScript的replace方法与正则表达式结合应用讲解