中国IT动力,最新最全的IT技术教程
最新100篇 | 推荐100篇 | 专题100篇 | 排行榜 | 搜索 | 在线API文档 | 网通镜像
首 页 | 程序开发 | 操作系统 | 软件应用 | 图形图象 | 网络应用 | 精文荟萃 | 教育认证 | 硬件维护 | 未整理篇 | 站长教程
ASP JS PHP工程 ASP.NET 网站建设 UML J2EESUN .NET VC VB VFP 网络维护 数据库 DB2 SQL2000 Oracle Mysql
服务器 Win2000 Office C DreamWeaver FireWorks Flash PhotoShop 上网宝典 CorelDraw 协议大全 网络安全 微软认证
硬件维护  CPU  主板  硬盘  内存  显卡  显示器  键盘鼠标  声卡音箱  打印机  机箱电源  BIOS  网卡  C#  Java  Delphi  vs.net2005
  当前位置:> 程序开发 > 编程语言 > .NET > 临时文章
前些时候做过的一份面试试题
作者:未知 时间:2005-07-27 21:39 出处:CSDN 责编:chinaitpower
              摘要:前些时候做过的一份面试试题

题目不算太简单,但因为开卷,所以稍为查了一下资料还是轻松完成。提交过去后,即得面试的机会,但当知道没有.Net实际开发经验时,三两下打发我了,没有音信!不过也是的,像我这样的程序员,只出道那么一年时间,有更多的不确定因素,凭什么给你机会呢。战战兢兢几个月了,都做了不少题,发觉有些企业会出一些手册性的题目,就是说太细,内容这么多太细谁记得住啊?真晕!今天想重ghost机器,差点把这删了,贴出来看看也好。

XX软件程序员测试题目

 

测试人姓名:_Kemin_____            

测试日期:___2004-11-2_____           完成测试时间:_____2004-11-2_________

 

本次测试共三道题目,要求如下:

1.  请用C#完成

2.  开卷独立完成,可以看书,上网等任何方式查找资料,但必须保证独立完成。一旦发现有不诚实行为,本公司将不予录取,后果自负。

 

题目一:

1.  编写冒泡排序程序

要求:

1)  请用C#编写一个冒泡排序的程序,

2)  要求排序的数据从文件C:\DATA.DAT中读取,数据间用逗号分隔。

解:

using System;

using System.IO;

class Test{

         static void BubbleSort(int[] ai) {

                   for (int j = ai.Length - 1; j > 0; j--){ // outer loop (backward)

                            for (int i = 0; i < j; i++) // inner loop (forward)

                                      if (ai[i] > ai[i+1])  Swap(ref ai[i], ref ai[i+1]);

                   }

         }

         static void Swap(ref int x,ref int y) {

                   x = x + y;

                   y = x - y;

                   x = x - y;

         }

         static void Main(string[] args) {

                   int[] ai = getData();

                   BubbleSort(ai);

                   foreach (int i in ai) Console.WriteLine(i);

                  Console.ReadLine();

         }

         public static int[] getData(){

                   try{

                      StreamReader sr = new StreamReader("data.dat");

                            string sLine;

                            sLine = sr.ReadLine();

                            string[] astr = sLine.Split(new Char[]{','});

                            int[] ai = new int[astr.Length];                     

                            for(int i = 0; i < astr.Length; i++)

                                     ai[i] = Convert.ToInt32(astr[i]);

                            return ai;

                   }

                   catch (Exception e)      {

                       // Let the user know what went wrong.

                       Console.WriteLine("The file could not be read:");

                       Console.WriteLine(e.Message);

                       return null;

                   }

         }

}

 

2.完成下面函数

         public static string Left(string sSource, int iLength)

         {

                   //完成类似于VBLeft函数的功能(返回字符串sSource的左iLength位的字符串)。

         }

解:

using System;

 

class Test{

    public static void Main(){

         //完成类似于VBLeft函数的功能(返回字符串sSource的左iLength位的字符串)。

         Console.WriteLine("Please enter a string to treaded:");

         string s = Console.ReadLine();

         int i = 0;

         bool bInputValid = false;

         while(!bInputValid){

                   try{

                            Console.WriteLine("Please enter the length from left most:");

                            i = Convert.ToInt32(Console.ReadLine());

                            if(i > s.Length) throw new Exception("");

                   }

                   catch(Exception e){

                            Console.WriteLine("It seen that your input data is not a integer or over flow, try again!");

                            Console.WriteLine(e.Message);

                            continue;

                   }

                   bInputValid = true;

         }

         Console.WriteLine("The left part string is {0} ", Left(s, i)); 

    }

         public static string Left(string sSource, int iLength){

                   char[] achar = new char[iLength];

                   for(int i = 0; i < iLength; i++)

                            achar[i] = sSource[i];//直接可字串中的单个字符,关键在这儿了

                   string sLeftPart = new string(achar);//直接构造回一个string

                   return sLeftPart;

         } 

}

 

2.   动物(animals)中的猫(cat)和狗(dog)都有咬(bit)的动作。请运用.net中对象的多态性技术展示猫咬和狗咬的动作。要求用C#代码实现。

 

 


 

解:

using System;

 

public class animals{

         //string sName;

         public virtual void bit(){

                   Console.Write("i am animals");

         }

}

 

public class dog : animals{

         public override void bit(){

                   Console.Write("bit by a dag!");

         }

}

 

public class cat : animals{

         public override void bit(){

                   Console.Write("bit by a cat!");

         }

}

 

public class Test{

         public static void Main(){

                   animals[] aa = new animals[2];

                   aa[0] = new dog();

                   aa[1] =  new cat();

                   foreach(animals a in aa) a.bit();

         } 

}


关闭本页
 
首页 | 投资与合作 | 服务条款 | 隐私政策 | 收藏本站 | 设为首页 | 新用户注册 | 免责声明 | 使用帮助
Copyright ©2005-2008 chinaitpower.com All rights reserved. www.chinaitpower.com 版权所有