A interview test question you have done before

xiaoxiao2021-03-06  42

The topic is not too simple, but because of the money, it is easy to check the information. After submitting the past, the opportunity to interview, but when you know if there is no .NET actual development experience, three or two times, don't have a message! But it is also, the programmer like me, only the one year, there are more uncertain factors, why give you the opportunity. After a few months of war, I have done a lot of questions. I found that some companies will have some man-book topics, that is, it is too thin, whose content is so much, who remembers? True! Today, I want to be the Ghost machine, I almost delete this, and I will have it. XX software programmer test topic

Tester Name: _KEMIN _____

Test Date: ___ 2004-11-2 _____ Complete Test Time: _____ 2004-11-2 _________

This test has a total of three topics, requiring the following:

1. Please use C # to complete

2. Opening is independently completed, you can read, online, etc. to find information, but you must guarantee independently. Once there is no honesty, the company will not be admitted and the consequences are at your own risk.

Topic one:

1. Write a bubbling order

Claim:

1) Please use C # to write a bubble order,

2) The data required to be sorted is read from the file c: /data.dat, and the data is separated by commas.

solution:

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

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

Ai [i] = convert.toint32 (astr [i]);

Return Ai;

}

Catch (Exception E) {

// let the user know what wrong.

Console.writeline ("The File Could Not Be Read:"); console.writeLine (E.MESSAGE);

Return NULL;

}

}

}

2. Complete the following functions

Public Static String Left (String Ssource, INT ILENGTH)

{

// Complete the function of the LEFT function similar to the VB (returns the string of the left Ilength bit of the string SSource).

}

solution:

Using system;

Class test {

Public static void

Main

() {

// Complete the function of the LEFT function similar to the VB (returns the string of the left Ilength bit of the string SSource).

Console.writeline ("please enter a string to turned:");

String s = console.readline ();

INT i = 0;

Bool binputvalid = false;

While (! binputvalid) {

Try {

Console.writeline ("please enter the length from left mot:");

I = Convert.Toint32 (console.readline ());

IF (i> s.ley) 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 [inength];

For (int i = 0; i

ACHAR [I] = SSource [i]; / / The key characters in the direct strings are here.

String SLEFTPART = New String (achar); // Directly construct back to a string

Return SLEFTPART;

}

}

2. Cats (CAT) and Dogs (DOG) in Animals have a bite (BIT). Please use the polymorphism technology of the object in .NET to show the action of the cat bites and dog biting. Require it with a C # code.

solution:

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 ();

}

}

转载请注明原文地址:https://www.9cbs.com/read-53948.html

New Post(0)