zoukankan      html  css  js  c++  java
  • 【学习笔记】递归算法+sql三种分页

    using Maticsoft.Common;
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    namespace Maticsoft.Web.cest
    {
        public partial class WebForm1 : System.Web.UI.Page
        {
            Maticsoft.BLL.lhzExcSQL lhz = new BLL.lhzExcSQL();
            protected void Page_Load(object sender, EventArgs e)
            {
                //Response.Write(Fun(4));
                if (!IsPostBack)
                {
                    Fun(30);
                }
            }
            //递归算法    1,1,2,3,5,8,13 求第n位数是多少?
            public int Fun(int n)
            {
                if (n < 1) return 0;
                if (n == 1 || n == 2) return 1;
                else return Fun(n - 1) + Fun(n - 2);
            }
            //三种常见分页
            //DataTable dt = lhz.GetTalbe("select nid,ntitle from news order by nid OFFSET (5 * (1-1)) ROW FETCH NEXT 5 rows only");
            //DataTable dt = lhz.GetTalbe("select top 5 nid,ntitle from news where nid not in (select top 0 nid from news order by nid) order by nid");
            //DataTable dt = lhz.GetTalbe("select * from (select top 5 nid,ntitle,ROW_NUMBER() over(order by nid) r from news) tt where tt.r between 1 and 5");
        }
    }
  • 相关阅读:
    HTML5之dir属性
    IPv4地址分类及子网划分
    二叉树的3种遍历
    js的点表示法和方括号表示法
    javascript-数组的常用方法
    第一编博文——漫长编程路
    使用qemu
    initial ram disk
    qemu常见选项解析
    cp和scp
  • 原文地址:https://www.cnblogs.com/kudsu/p/9205075.html
Copyright © 2011-2022 走看看