云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > C# ASP NET面试题附答案

C# ASP NET面试题附答案

  • 62 次阅读
  • 3 次下载
  • 2026/4/25 22:29:41

18. lpIter->Next = NULL; 19. LPLINKLIST lpPrev = NULL; 20. 21. bool bInserted = false; 22. for ( LPLINKLIST lpI = lpHead; 23. lpI != NULL; 24. lpPrev = lpI, lpI = lpI->Next ) 25. { 26. if ( lpIter->Value < lpI->Value ) 27. { 28. lpIter->Next = lpI; 29. if ( lpPrev == NULL ) 30. lpHead = lpIter; 31. else 32. lpPrev->Next = lpIter; 33. 34. bInserted = true; 35. break; 36. } 37. } 38. 39. if ( !bInserted ) 40. lpPrev->Next = lpIter; 41. 42. lpIter = lpNext; 43. } 44.

45. return lpHead; 46. }

Write a function to print the Fibonacci numbers.

int fib ( int n ) { if (n == 0) return 1; else return fib(n-1) + fib(n-2); }

int fibo (int n) { int i, current, one_back, two_back; if (n <= 1) return 1; else { one_back = 1; two_back = 1; for ( i = 2; i <= n; i++) { current = one_back + two_back; one_back = two_back; two_back = current; } /* end for loop */ } /* end else block */ return current; }

有一个有序数组,其中可能包含重复的元素,去除其重复的部分返回数组的长度。如一个数组包含:1,3,7,7,8,9,9,9,10,运行后应当为1,3,7,8,9,10,返回长度6。

private static int CountAfterRemoveDups(int[] data) {

if ( data == null ) throw new ArgumentNullException(\ if ( data.Length == 0 ) return 0;

int result = 1;

int lastNondup = data[0];

for ( int i = 1; i < data.Length; ++i ) {

if ( data[i] != lastNondup ) {

result++;

lastNondup = data[i]; } }

return result; }

将一个字符串中的整数输出(比如“14ab5eer87”,应该输出“14,5,87”)。易犯的错误:没有分组输出,即输出为14587了。

private static string PrintGroup(string data) {

if ( data == null ) throw new ArgumentNullException(\ char[] result = new char[data.Length];

int resultIter = 0; bool doGroup = false;

foreach ( char c in data ) {

if ( c >= '0' && c <= '9' ) {

result[resultIter++] = c; doGroup = true; } else {

if ( doGroup ) {

result[resultIter++] = ','; doGroup = false; } } }

return new string(result); }

Implement an algorithm to sort an array. Why did you pick the method you did?

Bubble sort:

for(int x=0; x

Quick Sort:

void swap(int *x,int *y) { int temp; temp = *x; *x = *y; *y = temp; }

int choose_pivot(int i,int j ) { return((i+j) /2); }

void quicksort(int list[],int m,int n) { int key,i,j,k; if( m < n) { k = choose_pivot(m,n); swap(&list[m],&list[k]); key = list[m]; i = m+1; j = n; while(i <= j) { while((i <= n) && (list[i] <= key)) i++; while((j >= m) && (list[j] > key)) j--; if( i < j) swap(&list[i],&list[j]); } // swap two elements swap(&list[m],&list[j]);

}

}

// recursively sort the lesser list quicksort(list,m,j-1); quicksort(list,j+1,n);

Insertion Sort:

void insertion_sort(int x[],int length) {

int key,i;

for(int j=1;j

key=x[j]; i=j-1;

while(x[i]>key && i>=0) {

x[i+1]=x[i]; i--; }

x[i+1]=key; } }

Switch every pair of words in a string (\

private static string ReverseWordPair(string input) {

if (string.IsNullOrEmpty(input))

throw new ArgumentNullException(\);

char[] result = new char[input.Length]; int resultIter = 0; int begin = 0;

// skip leading whitespace

while (begin < input.Length && input[begin] == ' ') {

result[resultIter++] = input[begin]; begin++; }

ReverseWordPairImp(result, resultIter, input, begin);

return new string(result); }

private static void ReverseWordPairImp(char[] result, int resultIter, string input, int inputIter) {

int[] indics = new int[2]; int i = inputIter;

indics[0] = inputIter;

for (; i < input.Length; ++i) {

搜索更多关于: C# ASP NET面试题附答案 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

18. lpIter->Next = NULL; 19. LPLINKLIST lpPrev = NULL; 20. 21. bool bInserted = false; 22. for ( LPLINKLIST lpI = lpHead; 23. lpI != NULL; 24. lpPrev = lpI, lpI = lpI->Next ) 25. { 26. if ( lpIter->Value Value ) 27. { 28. lpIter->Next = lpI; 29. if ( lpPrev == NULL ) 30. lpHead = lpIter; 31. else 32. lpPrev->Next

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com