第一范文网 - 专业文章范例文档资料分享平台

C# ASP NET面试题附答案

来源:用户分享 时间:2025/6/8 15:53:18 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

还是英文的哦!

Reverse a Singly Linked List without using Recursion.

///

/// Revert a single linked list ///

/// /// a single linked list

public static SingleLinkedListNode Reverse(SingleLinkedListNode root) {

if (root == null)

throw new ArgumentNullException(\);

SingleLinkedListNode iter = root, next = root.Next; SingleLinkedListNode newRoot = root; root.Next = null;

while (next != null) {

newRoot = next.Next; next.Next = iter; iter = next; next = newRoot; }

return iter; }

Reverse a Singly Linked List with using Recursion.

编程找出N以下的所有素数

void findPrimes(bignum topCandidate) { bignum candidate = 2; while(candidate <= topCandidate) { bignum trialDivisor = 2; int prime = 1; while(trialDivisor * trialDivisor <= candidate) { if(candidate % trialDivisor == 0) { prime = 0; break; } trialDivisor++; } if(prime) printPrime(candidate); candidate++; } }

Reverse every word in a String (abc def becomes cba fed).

1. private static string ReverseStringByWord(string input) 2. { 3. if (string.IsNullOrEmpty(input)) 4. throw new ArgumentNullException(\); 5. 6. char[] sb = new char[input.Length]; 7. int lastIndex = input.Length; 8. while ((lastIndex > 0) && char.IsWhiteSpace(input[lastIndex - 1])) lastIndex--; 9. 10. int appendIndex = 0; 11. for (int i = lastIndex - 1; i >= 0; i--) 12. { 13. char c = input[i]; 14. // if (char.IsWhiteSpace(input[i])) 15. if ( c == ' ' || c == '\\t' || c == '\\n' || c == '\\r' ) 16. { 17. for (int j = i + 1; j < lastIndex; ++j) 18. sb[appendIndex++] = input[j]; 19. 20. sb[appendIndex++] = input[i]; 21. lastIndex = i; 22. } 23. } 24. 25. for (int j = 0; j < lastIndex; ++j) 26. sb[appendIndex++] = input[j]; 27. 28. return new string(sb); 29. }

Write a function that takes in a string parameter and checks to see whether or not it is an integer, and if it is then return the integer value.

1. public static int Parse(string args) 2. {

3. // Author: Yimin Shi. 2008-05-30

4. // 这个函数也有一个BUG, 比如在处理字符串 \时候,就不会throw OverflowException.

5. if (string.IsNullOrEmpty(args))

6. throw new ArgumentNullException(\); 7.

8. int iter = 0;

9. bool bNegative = false; 10. int result = 0; 11. // Skip whites

12. while (iter < args.Length && (args[iter] == ' ')) iter++; 13.

14. if (args[iter] == '-') 15. {

16. bNegative = true; 17. iter++; 18. }

19. else if (args[iter] == '+') 20. iter++; 21.

22. for (; iter < args.Length; ++iter) 23. {

24. if (args[iter] >= '0' && args[iter] <= '9')

25. {

26. int cur = args[iter] - '0'; 32.

33. checked(result *= 10); 34.

35. result = bNegative ? result - cur 36. : result + cur; 42. } 43. else

44. break; 45. } 46.

47. // Skip whites

48. while (iter < args.Length && (args[iter] == ' ')) iter++; 49. if (iter != args.Length)

50. throw new ArgumentException(); 51.

52. return result; 53. }

Implement strstr() (or some other string library function).

char * __cdecl strstr ( const char * str1, const char * str2 ) {

char *cp = (char *) str1; char *s1, *s2;

if ( !*str2 )

return((char *)str1);

while (*cp) {

s1 = cp;

s2 = (char *) str2;

while ( *s1 && *s2 && !(*s1-*s2) ) s1++, s2++;

if (!*s2)

return(cp);

cp++; }

return(NULL); }

Implement an algorithm to print out all files below a given root node.

public abstract class AbstractGraph : AbstractContainer, Graph {

protected int numberOfVertices; protected int numberOfEdges; protected Vertex[] vertex;

public void BreadthFirstTraversal( Visitor visitor, int start) { bool[] enqueued = new bool[numberOfVertices]; for (int v = 0; v < numberOfVertices; ++v) enqueued[v] = false; Queue queue = new QueueAsLinkedList(); queue.Enqueue(vertex[start]); enqueued[start] = true; while (!queue.IsEmpty && !visitor.IsDone) { Vertex v = (Vertex)queue.Dequeue(); visitor.Visit(v); foreach (Vertex to in v.Successors) { if (!enqueued[to.Number]) { queue.Enqueue(to); enqueued[to.Number] = true; } } } } }

现有一单链表,输出从尾端开始的第5个数值,并写出相应的测试用例

Given two linked lists which have data in ascending order, how would you merge them

///

/// Merge two sorted linked list in sorted order ///

/// /// ///

/// The result sorted linked list ///

/// For e.g. ///

SingleLinkedListNode.PrintLinkedList(SingleLinkedListNode.OrderedMerge(SingleLinkedListNode.InitializeTestList(new int[] { 1, 2, 4, 5, 6, 7, 8, 9 }),

SingleLinkedListNode.InitializeTestList(new int[] { 3, 6, 8, 9, 10 }))); /// - returns -

/// 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 6 -> 7 -> 8 -> 8 -> 9 -> 9 -> 10 -> /// ///

SingleLinkedListNode.PrintLinkedList(SingleLinkedListNode.OrderedMerge(SingleLinkedListNode.InitializeTestList(new int[] { 1, 2, 4, 5, 7 }),

SingleLinkedListNode.InitializeTestList(new int[] { 3, 6, 8, 9, 10 }))); /// - returns -

/// 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 -> 8 -> 9 -> 10 -> ///

搜索更多关于: C# ASP NET面试题附答案 的文档
C# ASP NET面试题附答案.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c69bau6hyxa9ersb9r12w_1.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top