1.质数,1,3,5,7,X,能被1和本身整除
2.冒泡排序
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace 冒泡排序 { class Program { static void Main(string[] args) { int[] array = { 20, 40, 30, 10, 60, 50 }; foreach (var item in array) { Console.Write(item + " "); } Console.WriteLine(""); int[] aa = sort(array); foreach (var item in aa) { Console.Write(item + " "); } Console.ReadKey(); } /// <summary> /// 冒泡排序 /// </summary> /// <param name="m"></param> /// <returns></returns> public static int[] sort(int[] m) { //执行多少次 for (int i = 0; i < m.Length; i++) { //每执行1次,将最大的排在最后 //m.Length-1,因为 m[j + 1] <= m[5] for (int j = 0; j < m.Length - 1; j++) { int a = m[j]; int b = m[j + 1]; if (a > b) { m[j + 1] = a; m[j] = b; } } } return m; } } }
3.SQL分页,row=30,page=5
用ROW_NUMBER() over(order by XX)
select * from( select top(@PageSize*@PageIndex) ROW_NUMBER() over(order by ConID) as nid,* from dbo.PKE_DeviceContent ) as temp where temp.nid>(@PageSize*(@PageIndex-1)) ORDER BY temp.ConID
把查询的结果作为一个内查询,再在外面套上一个外查询语句:
--@PageIndex =5 --@PageSize=30 select * from( select top(30*5) ROW_NUMBER() over(order by ConID) as nid,* from dbo.PKE_DeviceContent ) as temp where temp.nid>(30*(5-1)) ORDER BY temp.ConID
参考:http://www.cnblogs.com/tangge/archive/2012/08/29/2662094.html
1