现在的位置: 首页 > 综合 > 正文

一些简单面试题

2012年02月09日 ⁄ 综合 ⁄ 共 796字 ⁄ 字号 评论关闭

今天看CSDN上有人分享这个,就5个简单问题,但是也惹来不少议论。在这里整理粘出来,看群众们有什么不一样的想法。(很多思想是在讨论的过程中学习的)

题目

1.说一下在C#中i++和++i的区别。
2.求1,1,2,3,5,8,13......(Fibonacci数列)第20项的值。
3.写出一个冒泡排序算法
4.设计一个无限分级的省市县数据库表。 
5.Sql Server2005数据库表TestTable的主键为ID int,写一个sql语句查询第20行至第30行的数据。

参考答案

1.i++先取值后运算,++1先运算后取值。
2.递归,if(i==0) return 1;else if(i==1)return 1;return Fabonacci(i-1)+Fabonacci(i-2);
3

int[] list = new int[5] { 1, 4, 2, 5, 3 };
            for (int j = 0; j < list.Length; j++)  
            {  
              for (int i = list.Length - 1; i > j; i--)  
              {
                  if (list[j] < list[i])
                  {
                     int temp = list[j];
                      list[j] = list[i];
                      list[i] = temp;
                  }
              }  
            }

4.ID [Name] ParentID
5.select top 30 * from TestTable where ID not in(select top 20 ID from TestTable)

with test as
(
    select TestTable.*,row_number() over(order by id) as rownumber from TestTable
)
select * from test where rownumber between 10 and 20

发挥你们的想象吧。

原题地址http://topic.csdn.net/u/20110720/09/374b5918-d52c-4f04-9bd0-279d6f53fc62.html

抱歉!评论已关闭.