2006年10月北京中软笔试题

出自求职百科

跳转到: 导航, 搜索

北京中软笔试题

1.不许用中间变量,把String ABCDE 倒转

2.10000个数求第2大的数,不许用排序算法.

3.排序算法的测试用例

我的答案:

1.

  1. include "stdafx.h"
  1. include <iostream>
  1. include <string>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])

{

 char *ps = new char[15];

 strcpy_s(ps,15,"I am yuchifang");

 cout<<"before reverse:"<<endl;

 cout<<ps<<endl;

 int i = 0;

 int j = 13;

 while(i<j)

 {

 ps[i] = ps[i]+ps[j];

 ps[j] = ps[i]-ps[j];

 ps[i] = ps[i]-ps[j];

 i++;

 j--;

 }

 cout<<"after reverse"<<endl;

 cout<<ps<<endl;

 return 0;

}

个人工具
公司索引
  • A   B   C   D   E   F   G
  • H   I   J   K   L   M   N
  • O    P
  •     Q    R    S    T
  • U    V    W    X    Y    Z
工具箱