zoukankan      html  css  js  c++  java
  • 最新的.Net面试题及答案

    1:a=10,b=15,在不用第三方变题的前提下,把a,b的值互换
       a=a+b;b=a-b;a=(a-b)/2;b=b+a
    2:已知数组int[] max={6,5,2,9,7,4,0};用快速排序算法按降序对其进行排列,并返回数组
       using System;

    namespace VcQuickSort
    {
    /// <summary>
    /// ClassQuickSort 快速排序。
    /// 范维肖
    /// </summary>
    public class QuickSort
    {
    public QuickSort()
    {
    }

    private void Swap(ref int i,ref int j)
    //swap two integer
    {
    int t;
    t=i;
    i=j;
    j=t;
    }

    public void Sort(int [] list,int low,int high)
    {
    if(high<=low)
    {
    //only one element in array list
    //so it do not need sort
    return;
    }
    else if (high==low+1)
    {
    //means two elements in array list
    //so we just compare them
    if(list[low]>list[high])
    {
    //exchange them
    Swap(ref list[low],ref list[high]);
    return;
    }
    }
    //more than 3 elements in the arrary list
    //begin QuickSort
    myQuickSort(list,low,high);
    }

    public void myQuickSort(int [] list,int low,int high)
    {
    if(low<high)
    {
    int pivot=Partition(list,low,high);
    myQuickSort(list,low,pivot-1);
    myQuickSort(list,pivot+1,high);
    }
    }

    private int Partition(int [] list,int low,int high)
    {
    //get the pivot of the arrary list
    int pivot;
    pivot=list[low];
    while(low<high)
    {
    while(low<high && list[high]>=pivot)
    {
    high--;
    }
    if(low!=high)
    {
    Swap(ref list[low],ref list[high]);
    low++;
    }
    while(low<high && list[low]<=pivot)
    {
    low++;
    }
    if(low!=high)
    {
    Swap(ref list[low],ref list[high]);
    high--;
    }
    }
    return low;
    }

    }
    }
    3:请简述面向对象的多态的特性及意义!
    在c#中多态性的定义是:同一操作作用于不同的类的实例、不同的类将进行不同的解释、最后产生不同的执行结果。

    c#支持两种类型的多态性:
    编译时的多态性(静态联编
    编译时的多态性是通过重载来实现的。方法重载和操作符重载、它们都实现了编译时的多态性。
    对于非虚的成员来说系统在编译时根据传递的参数、返回的类型等信息决定实现何种操作。
    运行时的多态性(动态联编
    运行时的多态性就是指直到系统运行时才根据实际情况决定实现何种操作c#中运行时的多态性。
    通过虚成员实现
    编译时的多态性为我们提供了运行速度快的特点而运行时的多态性则带来了高度灵活和抽象的特点


    4:session喜欢丢值且占内存,Cookis不安全,请问用什么办法代替这两种原始的方法
        用VIEWSTATE /Profile/自己在服务器端实现个Cache
    5:对数据的并发采用什么办法进行处理较好。
       1、使用事务对象:
     1SqlConnection   conn   =   new   SqlConnection(ConnectionString);   
     2  SqlCommand   cmd   =   new   SqlCommand("delete   from   table_a   where   bh=1",conn);   
     3  SqlTransaction   Trans   ;   //事物对象   
     4    
     5  conn.Open();   
     6  Trans   =   conn.BeginTransaction(IsolationLevel.ReadCommitted,   "MyTrans");   
     7  cmd.Transaction   =   Trans;   
     8  try{   
     9  cmd.ExecuteNonQuery();   
    10                    //如果成功,则提交数据   
    11  Trans.Commit();   
    12  }
       
    13  catch   (SqlException   Err){   
    14                  //产生错误,则回滚事物对象   
    15  Trans.Rollback("MyTrans");   
    16  }
       
    17  finally{   
    18  conn.Close();   
    19  }
       
    2、 使用lock()  unlock()
    3、使用时间戳,使用timetamp类型。
    6:已知Oracle数据库有GD和ZS两个数据库,GD数据库v_s表有数据写入时,从v_s表中提取最新数据到ZS数据库的D_E表中。请问用什么办法解决这一问题?如果又碰到不能互访的问题时,又用什么办法解决?

    7:已知Oracle数据库a,b
    现在在a用户权限下,访问b数据库sql语句为select a.* From b a,请改正这一句Sql的写法

    8:当对数据库进行海量级的数据插入时,数据库出现报错,错误原因可能有哪些,以你的经验谈谈你的解决办法

    9:算法分析
    AH 20060625 12 44 01 CAD001
    AH 20060625 12 44 01 CAD001
    AH 20060625 13 44 02 CAD001
    AH 20060625 14 44 03 CAD001
    说明:第二列表示日期,第三列表示温度,第四列表示水位,第五列表示流量,第6列表示水位测站编码,每一列表示一个字段
    很明显第一条数据和第二条数据重复,然数据表中有主键和外键的约束,是不允许有重复的数据存在的,请构造算法将重复的数据Del掉

    10:javascript算法
    已知a,b,现在点鼠标a会向b游动,鼠标停,a会停下来
    请实现"跑步算法"
  • 相关阅读:
    GraphX学习笔记——Programming Guide
    GraphX学习笔记——可视化
    Gephi学习笔记
    Ubuntu16.04安装apache-airflow
    Centos7.0下MySQL的安装
    同时安装anaconda2和anaconda3
    Hive学习笔记——安装和内部表CRUD
    Python爬虫学习——布隆过滤器
    Ubuntu下安装和使用zookeeper和kafka
    Ubuntu16.04安装xgboost
  • 原文地址:https://www.cnblogs.com/dylan/p/755782.html
Copyright © 2011-2022 走看看