.net面试题及答案二

2:已知数组int[] max={6,5,2,9,7,4,0};用快速排序算法按降序对其进行排列,并返回数组
答:public class TestQuickSort {

private int[] array = null;

private void quickSort(int lowest, int highest) {
if (array == null || lowest < 0 || lowest >= highest
|| highest >= array.length) {
return;
}
int low = lowest;
int high = highest;
int key = low++;
for (; low <= high;) {
if (key < high) {
if (array[key] > array[high]) {
array[high] = array[key] + (array[key] = array[high]) * 0;
key = high;
}
high--;
}

if (key > low) {
if (array[key] < array[low]) {
array[low] = array[key] + (array[key] = array[low]) * 0;
key = low;
}
low++;
}
}
quickSort(lowest, key - 1);
quickSort(key + 1, highest);
}

/**
* @param args
*/
public static void main(String[] args) {
TestQuickSort test = new TestQuickSort();
int[] array = {6,5,2,9,7,4,0};
test.array = array;
test.quickSort(0, array.length - 1);
int length = test.array.length;
for (int i = 0; i < length; i++) {
System.out.println(test.array[i]);
}
}
}
快速排序是综合性能最好的内部排序算法!

3:请简述面向对象的多态的特性及意义!
答:多态:面向对象的语言使用虚方法表达多态。这就意味着派生类可以有和父类具有同样签名的方法,并且父类可以调用派生类的方法。在C#中,必须使用virtual关键字才能使方法被父类调用。这使得一个对象在不同的环境中有不同的动作形态。

5:对数据的并发采用什么办法进行处理较好。
答:可以控制连接池的连接数量 条件好的话 可以用负载平衡


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的写法

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掉
答:alter table 表 add ID int identity(1,1)
delete 表
where newfield not in
(
select top 1 ID from 表 group by 日期,温度,水位,流量,水位测站编码
)
alter table 表 drop column ID


10:javascript算法
已知a,b,现在点鼠标a会向b游动,鼠标停,a会停下来
请实现"跑步算法"
答:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd%22%3E
<html>
<head>
<title>JavaScript</title>
<style>
html
{
background-color:silver;
}
.point1
{
position:absolute;
left:10px;
top:40px;

}
.point2
{
position:absolute;
left:100px;
top:40px;
}
.hr1
{
position:absolute;
top:60px;
}
</style>
<script type="text/JavaScript">
document.onmousedown = mousedown;
document.onmouseup = mouseup;
var intervalProcess;
var direct = true;
function mousedown(){
intervalProcess = setInterval("MovePoint()", 1);
}
function mouseup(){
clearInterval(intervalProcess);
}
function MovePoint(){
with (document.getElementById("point1").style){
if (isNaN(parseInt(left)))
left = "10px";
else {
document.getElementById("point2").style.left = "200px";
if (parseInt(left) < 0)
direct = true;
if (parseInt(left) > parseInt(document.getElementById("point2").style.left))
direct = false;
if (direct)
left = parseInt(left) + 1 + "px";
else
left = parseInt(left) - 1 + "px";
}
}
}
</script>
</head>
<body>
<div class="point1" id="point1"><font color=blue>a</font></div>
<div class="point2" id="point2"><font color=red>b</font></div>
<hr class="hr1" />
</body>
</html>

原文地址:https://www.cnblogs.com/colder/p/1676677.html