总结一些常考的面试题目

又到了一年一度的毕业季,终于要踏上社会出去找工作了,因为想找一份C#/.NET开发工程师的工作,所以最近一直在刷一些关于C#/.NET的面试题,顺便归纳了一些面试常考的又需要手写代码的题目。

1、冒泡排序
int a = 0;
int[] myint = new int[] { 3, 82, 9, 1, 32, 78 };
for (int i = 0; i < myint.Length - 1; i++){
   for (int j = 0; j < myint.Length - 1 - i; j++){
           if (myint[j] < myint[j + 1]){
                        a = myint[j];
                        myint[j] = myint[j + 1];
                        myint[j + 1] = a;
              }
       }
}
foreach (int number in myint){
     Console.WriteLine(number + "");
}
Console.ReadKey();
2、随机插入10位不同的数字
int[] myint = new int[10];
ArrayList mylist = new ArrayList();
Random ran = new Random();
while (mylist.Count < 10){
    int num = ran.Next(1, 11);
    if (!mylist.Contains(num)){
       mylist.Add(num);
    }
}
for (int i = 0; i < 10; i++){
     myint[i] = (int)mylist[i];
     Console.WriteLine(myint[i]);
}
3、计算数组中不重复的数字个数
int[] myint = { 3, 5, 2, 2, 6, 3 };
HashSet<int> set = new HashSet<int>();
foreach (int i in myint){
    set.Add(i);
}
Console.WriteLine(set.Count);
4、判断字母大小写
Console.WriteLine("请输入一个字母");
char ch = char.Parse(Console.ReadLine());
if (ch >= 'a' && ch <= 'z'){
    Console.WriteLine("小写");
}else{
    Console.WriteLine("大写");
}
5、ajax无刷新登录
window.onload = function(){
decument.getElementById("btn").onclick = function(){
var username = document.getElementById("uname").value;
var password = document.getElementById("pas").value;
var xmh = window.XMLHttpRequest ? new XMLHttpRequest() : new Activexobject("Microsoft.XMLHTTP");
xmh.open("post", "/Hander1.ashx?username=" + username + "&password=" + password, true);
xmh.onreadystateChange = function(){
if (xmh.readystate == 4){
   if (xmh.status == 200){
       var X = JSON.Parse(xmh.responText);
       alert(X.status);
    }
}else{
  Console.WriteLine("错误");
}
}
xmh send();
}
}
6、用递归计算1,1,2,3,5,8,13......30位?
Console.WriteLine(Foo(30));
public static int Foo(int i){
if (i <= 0)
  return 0;
  else if (i > 0 && i <= 2)
  return 1;
else return Foo(i - 1) + Foo(i - 2);
}

好了,虽然总结的不多,但都是常考的一些面试题,希望能帮得到大家。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值