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_intforumid
int,
9@a_intpageno
int,
10@a_intpagesize
int11
as12
/*定義區域性變數
*/13
declare
@intbeginid
int14
declare
@intendid
int15
declare
@introotrecordcount
int16
declare
@intpagecount
int17
declare
@introwcount
int18
/*關閉計數
*/19
setnocount
on20
21/*
檢測是否有這個版面
*/22
ifnot
exists
(select
*from
forum
where
id =
@a_intforumid
) 23
return(-
1) 2425
/*求總共根貼數
*/26
select
@introotrecordcount
=count(*
) from
bbs
where
fatherid=0
andforumid
=@a_intforumid
27if
(@introotrecordcount=0
) --
如果沒有貼子,則返回零
28return029
30/*
判斷頁數是否正確
*/31if(
@a_intpageno-1
) *@a_intpagesize
>
@introotrecordcount
32return(-
1) 3334
/*求開始rootid
*/35
set@introwcount=(
@a_intpageno-1
) *@a_intpagesize+1
36/*
限制條數
*/37
setrowcount
@introwcount
38select
@intbeginid
=rootid
from
bbs
where
fatherid=0
andforumid
=@a_intforumid
39order
byid
desc
4041
/*結束rootid
*/42
set@introwcount
=@a_intpageno
*@a_intpagesize
43/*
限制條數
*/44
setrowcount
@introwcount
45select
@intendid
=rootid
from
bbs
where
fatherid=0
andforumid
=@a_intforumid
46order
byid
desc
4748
/*恢復系統變數
*/49
setrowcount050
setnocount
off51
52select
a.id , a.layer , a.forumid , a.subject , a.faceid , a.hits , a.time , a.userid , a.fatherid ,
53a.rootid ,
54''''
bytes
''''
=datalength
(a.content) , b.username , b.email , b.homepage , b.signature , b.point
55from
bbs
asa
join
bbsuser
asb
ona.userid
=b.id
56where
forumid
=@a_intforumid
anda.rootid
between
@intendid
and@intbeginid
57order
bya.rootid
desc
, a.ordernum
desc
58return
(@@rowcount
) 59
--select @@rowcount
60go
最小最大和 Standard IO
description alice和bob在玩乙個遊戲,每一輪bob都會給alice兩個整數a和b 1 a,b 100 alice每一輪必須把目前所有的a序列和b序列中的數一一配對,每個數必須用且只使用一次,要求最大和最小。題解數值大小比較小,用乙個陣列統計,再用桶優化,暴力 沒了。var i,j,...
二叉樹深度(最大和最小)
最大深度 definition for a binary tree node.struct treenode int maxdepth struct treenode root 二叉樹類的問題都會考慮採用遞迴的方式進行求解,因為二叉樹本身就是遞迴定義的。最小深度int mindepth treeno...
求最大和最小值 SDIBTOJ 2001
time limit 1 sec memory limit 64 mb submit 2661 solved 965 submit status discuss description 給定n個數,在最壞情況下用 3n 2 2 次比較找出這n個數中元素的最大值和最小值。要求只編寫函式 void ma...