<?php
// $poker[0] 撲克牌花色 1~4 代表黑桃 黑桃 梅花 方塊
// $poker[1] 撲克牌數字 1~13 代表1~10 j q k
$poker
=array(0
=>
array(0
=>1,
1=>2,
2=>1,
3=>4,
4=>1,
5=>3,
6=>2)
,1=>
array(0
=>1,
1=>6,
2=>9,
3=>10,
4=>11,
5=>12,
6=>13)
);$max_flush_count=7
;var_dump
(get_straight_flush
($poker
,$max_flush_count))
;$poker=[
[1,1
,1,1
,1,1
,1],
[5,6
,7,8
,9,10
,11]]
;//7,8,9,10,11
var_dump
(get_straight_flush
($poker
,$max_flush_count))
;$poker=[
[1,1
,1,1
,1,1
,1],
[5,6
,7,8
,9,10
,12]]
;//678910
var_dump
(get_straight_flush
($poker
,$max_flush_count))
;$poker=[
[1,1
,1,1
,1,1
,1],
[3,4
,7,8
,9,10
,11]]
;//7,8,9,10,11
var_dump
(get_straight_flush
($poker
,$max_flush_count))
;$poker=[
[1,1
,1,1
,1,1
,1],
[2,4
,5,6
,7,8
,10]]
;//4,5,6,7,8,
var_dump
(get_straight_flush
($poker
,$max_flush_count))
;$poker=[
[1,1
,1,1
,1,1
,1],
[2,4
,5,6
,7,8
,11]]
;//4,5,6,7,8,
var_dump
(get_straight_flush
($poker
,$max_flush_count))
;$poker=[
[1,1
,1,1
,1,1
,1],
[1,2
,4,5
,6,8
,11]]
;//1568 11 無序
var_dump
(get_straight_flush
($poker
,$max_flush_count))
;$poker=[
[1,1
,1,1
,1,1
,1],
[2,4
,5,6
,7,9
,11]]
;//5,6,7,9,11 無序
var_dump
(get_straight_flush
($poker
,$max_flush_count))
;$max_flush_count=6
;$poker=[
[1,1
,1,1
,1,1
],[6
,7,8
,9,10
,11]]
;//7,8,9,10,11
var_dump
(get_straight_flush
($poker
,$max_flush_count))
;$poker=[
[1,1
,1,1
,1,1
],[6
,7,8
,9,10
,12]]
;//6,7,8,9,10
var_dump
(get_straight_flush
($poker
,$max_flush_count))
;// exit;
$poker=[
[1,1
,1,1
,1,1
],[5
,7,8
,9,10
,11]]
;//7,8,9,10,11
var_dump
(get_straight_flush
($poker
,$max_flush_count))
;$poker=[
[1,1
,1,1
,1,1
],[5
,7,8
,9,11
,12]]
;//7,8,9,11,12 無序
var_dump
(get_straight_flush
($poker
,$max_flush_count))
;$poker=[
[1,1
,1,1
,1,1
],[1
,7,8
,9,11
,12]]
;//1,8,9,11,12 無序
var_dump
(get_straight_flush
($poker
,$max_flush_count))
;$max_flush_count=5
;$poker=[
[1,1
,1,1
,1],
[7,8
,9,10
,11]]
;//7,8,9,10,11
var_dump
(get_straight_flush
($poker
,$max_flush_count))
;$poker=[
[1,1
,1,1
,1,1
],[7
,8,9
,10,12
]];//7,8,9,10,12
var_dump
(get_straight_flush
($poker
,$max_flush_count))
;$poker=[
[1,1
,1,1
,1,1
],[1
,7,8
,9,10
]];//1,7,8,9,10 無序
var_dump
(get_straight_flush
($poker
,$max_flush_count))
;/**
* [get_straight_flush 統計出同花順]
* @param [type] $result_poker [玩家撲克牌]
* @param [type] $max_flush_count [最大同花數量]
*/function
get_straight_flush
($result_poker
,$max_flush_count
)elseif(
$result_poker[1
][0]
==1&&$result_poker[1
][4]
==5)else
}break;}
}//不是順子 說明都是單數 求出最大牌if(
$poker_level==6
)}else}}
}}}return
array
('poker_level'
=>
$poker_level
,'result_poker'
=>
$result_poker);
}
使用求出最大和最小ID進行分頁
1乙個bbs的分頁 23 ifexists select from sysobjects where id object id up gettopiclist 4 drop proc up gettopiclist 5go 67create proc up gettopiclist 8 a intf...
演算法導論 同時求出最大值最小值的方法
核心思想 假設陣列中有n個元素,n有兩種情況 1.若n是奇數,就將最大值和最小值的初值都設為第乙個元素的值。2.若n是偶數,就將陣列中前兩個元素互相比較一次,將最小值的初值設定成較小者,將最大者的初值設定成較大者。最後,在n分完奇偶,且最大值最小值設定完後,將餘下的元素成對的處理,即兩個兩個元素相互...
c語言 運用遞迴演算法求出陣列中的最大值
思考題 如何用遞迴求出陣列中的最大項 解 我們很簡單的把乙個擁有n個數字的int型別的陣列看成兩個部分,前n 1項和第n項 在進行比較大小的時候,就直接拿前n 1項和第n項進行比較 如果第n項比較大,就return出第n項 如果前n 1項比第n項要大,就用遞迴的方法return出前n 1項的最大值 ...