激情欧美日韩一区二区,浪货撅高贱屁股求主人调教视频,精品无码成人片一区二区98,国产高清av在线播放,色翁荡息又大又硬又粗视频

10道有代表性面試題整理

時(shí)間:2024-08-31 08:10:26 綜合指導 我要投稿
  • 相關(guān)推薦

10道有代表性面試題整理

  現在的公司招聘,都要筆試面試.如果你不是那種編程功底非常深厚的人,又不好好準備一番,在筆試面試中往往會(huì )處于被動(dòng)局面.雖然有些筆試題是故意為難我們,有點(diǎn)鉆牛角尖.但是很多筆試題面試題確實(shí)能夠很好地看出我們的基礎.

10道有代表性面試題整理

  在這里,我就略去那些鉆牛角尖的題.從csdn論壇我近半年的收集中選出10道有代表性的題目,難度基本上是逐漸加大.對數組,指針,數據結構,算法,字符串,文件操作等問(wèn)題都有覆蓋.主要以c語(yǔ)言的實(shí)現為主,也有c++的題.大家可以先做做這10道題,測試一下自己的水平.

  1. 下面這段代碼的輸出是多少(在32位機上).

  char *p;

  char *q[20];

  char *m[20][20];

  int (*n)[10];

  struct MyStruct

  {

  char dda;

  double dda1;

  int type ;

  };

  MyStruct k;

  printf("%d %d %d %d",sizeof(p),sizeof(q),sizeof(m),sizeof(n),sizeof(k));

  2.

  (1)

  char a[2][2][3]={{{1,6,3},{5,4,15}},{{3,5,33},{23,12,7}} };

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

  printf("%d ",_______);

  在空格處填上合適的語(yǔ)句,順序打印出a中的數字

  (2)

  char **p, a[16][8];

  問(wèn):p=a是否會(huì )導致程序在以后出現問(wèn)題?為什么?

  3.用遞歸方式,非遞歸方式寫(xiě)函數將一個(gè)字符串反轉.

  函數原型如下:char *reverse(char *str);

  4.strcpy函數和memcpy函數有什么區別?它們各自使用時(shí)應該注意什么問(wèn)題?

  5.寫(xiě)一個(gè)函數將一個(gè)鏈表逆序.

  一個(gè)單鏈表,不知道長(cháng)度,寫(xiě)一個(gè)函數快速找到中間節點(diǎn)的位置.

  寫(xiě)一個(gè)函數找出一個(gè)單向鏈表的倒數第n個(gè)節點(diǎn)的指針.(把能想到的最好算法寫(xiě)出).

  6.用遞歸算法判斷數組a[N]是否為一個(gè)遞增數組。

  7.

  有一個(gè)文件(名為a.txt)如下,每行有4項,第一項是他們的名次,寫(xiě)一個(gè)c程序,將五個(gè)人的名字打印出來(lái).并按名次排序后將5行數據仍然保存到a.txt中.使文件按名次排列每行.

  2,07010188,0711,李鎮豪,

  1,07010154,0421,陳亦良,

  3,07010194,0312,凌瑞松,

  4,07010209,0351,羅安祥,

  5,07010237,0961,黃世傳,

  8.寫(xiě)一個(gè)函數,判斷一個(gè)unsigned char 字符有幾位是1.

  寫(xiě)一個(gè)函數判斷計算機的字節存儲順序是升序(little-endian)還是降序(big-endian).

  9.微軟的筆試題.

  Implement a string class in C++ with basic functionality like comparison, concatenation, input and output. Please also provide some test cases and using scenarios (sample code of using this class).

  Please do not use MFC, STL and other libraries in your implementation.

  10.有個(gè)數組a[100]存放了100個(gè)數,這100個(gè)數取自1-99,且只有兩個(gè)相同的數,剩下的98個(gè)數不同,寫(xiě)一個(gè)搜索算法找出相同的那個(gè)數的值.(注意空間效率時(shí)間效率盡可能要低).

  這十道題還是能夠看出自己的水平如何的.如果你能不假思索地做出這10道題,估計去國外大公司是沒(méi)有問(wèn)題了,呵呵.

  答案我在整理中,以后陸續發(fā)布.................

  下面有些題也不錯,可以參考.

  1.下面的代碼輸出是什么,為什么?

  void foo(void)

  {

  unsigned int a = 6;

  int b = -20;

  (a+b>6)?puts(">6"):puts("<=6");//puts為打印函數

  }

  輸出 >6.

  就是考察隱式轉換.int型變量轉化成unsigned int, b成了正數.

  2. b)運行下面的函數會(huì )有什么結果?為什么?

  void foo(void)

  {

  char string[10],str1[10];

  int i;

  for(i=0;i<10;i++)

  {

  str1 = a;

  }

  strcpy(string, str1);

  printf("%s",string);

  }

  首先搞清strcpy函數的實(shí)現方法,

  char * strcpy(char * strDest,const char * strSrc)

  {

  if ((strDest == NULL) || (strSrc == NULL))

  throw "Invalid argument(s)";

  char * strDestCopy = strDest;

  while ((*strDest++ = *strSrc++) != \0);

  return strDestCopy;

  }

  由于str1末尾沒(méi)有\0’結束標志,所以strcpy不知道拷貝到何時(shí)結束.

  printf函數,對于輸出char* 類(lèi)型,順序打印字符串中的字符直到遇到空字符('\0')或已打印了由精度指定的字符數為止.

  下面是微軟的兩道筆試題....

  3. Implement a string class in C++ with basic functionality like comparison, concatenation, input and output. Please also provide some test cases and using scenarios (sample code of using this class).

  Please do not use MFC, STL and other libraries in your implementation.

  我的實(shí)現方案如下,這道題真地對c++的主要特性都進(jìn)行了較好地考察.

  String.h:

  #ifndef STRING_H

  #define STRING_H

  #include

  using namespace std;

  class String{

  public:

  String();

  String(int n,char c);

  String(const char* source);

  String(const String& s);

  //String& operator=(char* s);

  String& operator=(const String& s);

  ~String();

  char& operator[](int i){return a;}

  const char& operator[](int i) const {return a;}//對常量的索引.

  String& operator+=(const String& s);

  int length();

  friend istream& operator>>(istream& is, String& s);//搞清為什么將>>設置為友元函數的原因.

  //friend bool operator< (const String& left,const String& right);

  friend bool operator> (const String& left, const String& right);//下面三個(gè)運算符都沒(méi)必要設成友元函數,這里是為了簡(jiǎn)單.

  friend bool operator== (const String& left, const String& right);

  friend bool operator!= (const String& left, const String& right);

  private:

  char* a;

  int size;

  };

  #endif

  String.cpp:

  #include "String.h"

  #include

  #include

  String::String(){

  a = new char[1];

  a[0] = \0;

  size = 0;

  }

  String::String(int n,char c){

  a = new char[n + 1];

  memset(a,c,n);

  a[n] = \0;

  size = n;

  }

  String::String(const char* source){

  if(source == NULL){

  a = new char[1];

  a[0] = \0;

  size = 0;

  }

  else

  { size = strlen(source);

  a = new char[size + 1];

  strcpy(a,source);

  }

  }

  String::String(const String& s){

  size = strlen(s.a);//可以訪(fǎng)問(wèn)私有變量.

  a = new char[size + 1];

  //if(a == NULL)

  strcpy(a,s.a);

  }

  String& String::operator=(const String& s){

  if(this == &s)

  return *this;

  else

  {

  [] a;

  size = strlen(s.a);

  a = new char[size + 1];

  strcpy(a,s.a);

  return *this;

  }

  }

  String::~String(){

  [] a;//

  }

  String& String::operator+=(const String& s){

  int j = strlen(a);

  int size = j + strlen(s.a);

  char* tmp = new char[size+1];

  strcpy(tmp,a);

  strcpy(tmp+j,s.a);

  [] a;

  a = tmp;

  return *this;

  }

  int String::length(){

  return strlen(a);

  }

  main.cpp:

  #include

  #include "String.h"

  using namespace std;

  bool operator==(const String& left, const String& right)

  {

  int a = strcmp(left.a,right.a);

  if(a == 0)

  return true;

  else

  return false;

  }

  bool operator!=(const String& left, const String& right)

  {

  return !(left == right);

  }

  ostream& operator<<(ostream& os,String& s){

  int length = s.length();

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

  //os << s.a;這么不行,私有變量.

  os << s;

  return os;

  }

  String operator+(const String& a,const String& b){

  String temp;

  temp = a;

  temp += b;

  return temp;

  }

  bool operator<(const String& left,const String& right){

  int j = 0;

  while((left[j] != \0) && (right[j] != \0)){

  if(left[j] < right[j])

  return true;

  else

  {

  if(left[j] == right[j]){

  j++;

  continue;

  }

  else

  return false;

  }

  }

  if((left[j] == \0) && (right[j] != \0))

  return true;

  else

  return false;

  }

  bool operator>(const String& left, const String& right)

  { int a = strcmp(left.a,right.a);

  if(a > 0)

  return true;

  else

  return false;

  }

  istream& operator>>(istream& is, String& s){

  [] s.a;

  s.a = new char[20];

  int m = 20;

  char c;

  int i = 0;

  while (is.get(c) && isspace(c));

  if (is) {

  do {s.a = c;

  i++;

  /*if(i >= 20){

  cout << "Input too much characters!" << endl;

  exit(-1);

  }*/

  if(i == m - 1 ){

  s.a = \0;

  char* b = new char[m];

  strcpy(b,s.a);

  m = m * 2;

  s.a = new char[m];

  strcpy(s.a,b);

  [] b;

  }

  }

  while (is.get(c) && !isspace(c));

  //如果讀到空白,將其放回.

  if (is)

  is.unget();

  }

  s.size = i;

  s.a = \0;

  return is;

  }

  int main(){

  String a = "abcd";

  String b = "www";

  //String c(6,b);這么寫(xiě)不對.

  String c(6,l);

  String d;

  String e = a;//abcd

  String f;

  cin >> f;//需要輸入...

  String g;

  g = a + b;//abcdwww

  if(a < b)

  cout << "a < b" << endl;

  else

  cout << "a >= b" << endl;

  if(e == a)

  cout << "e == a" << endl;

  else

  cout << "e != a" << endl;

  b += a;

  cout << a << endl;

  cout << b << endl;

  cout << c << endl;

  cout << d << endl;

  cout << e << endl;

  cout << f << endl;

  cout << g << endl;

  cout << g[0] << endl;

  return 0;

  }

  4. Implement a single-direction linked list sorting algorithm. Please first define the data structure of linked list and then implement the sorting algorithm.

  5.編寫(xiě)一個(gè)函數,返回兩個(gè)字符串的最大公串!例如,“adbccadebbca”和“edabccadece”,返回“ccade”

  聯(lián)想筆試題

  1.設計函數 int atoi(char *s)。

  int atoi(const char *nptr);

  函數說(shuō)明

  atoi()會(huì )掃描參數nptr字符串,跳過(guò)前面的空格字符,直到遇上數字或正負符號才開(kāi)始做轉換,而再 遇到非數字或字符串結束時(shí)(\0)才結束轉換,并將結果返回。

  返回值 返回轉換后的整型數。

  #include

  #include

  int myAtoi(const char* s){

  int result = 0;

  int flag = 1;

  int i = 0;

  while(isspace(s))

  i++;

  if(s == -){

  flag = -1;

  i++;

  }

  if(s == +)

  i++;

  while(s != \0){

  if((s > 9) || (s < 0))

  break;

  int j = s - 0;

  result = 10 * result + j;

  i++;

  }

  result = result * flag;

  return result;

  }

  int main(){

  char* a = " -1234def";

  char* b = "+1234";

  int i = myAtoi(a);

  int j = myAtoi(b);

  printf("%d \n",i);

  printf("%d",j);

  return 0;

  }

  2.int i=(j=4,k=8,l=16,m=32); printf(“%d”, i); 輸出是多少?

  3.解釋局部變量、全局變量和靜態(tài)變量的含義。

  4.解釋堆和棧的區別。

  5.論述含參數的宏與函數的優(yōu)缺點(diǎn)。

  普天C++筆試題

  1.實(shí)現雙向鏈表刪除一個(gè)節點(diǎn)P,在節點(diǎn)P后插入一個(gè)節點(diǎn),寫(xiě)出這兩個(gè)函數。

  2.寫(xiě)一個(gè)函數,將其中的\t都轉換成4個(gè)空格。

  3.Windows程序的入口是哪里?寫(xiě)出Windows消息機制的流程。

  4.如何定義和實(shí)現一個(gè)類(lèi)的成員函數為回調函數?

  5.C++里面是不是所有的動(dòng)作都是main()引起的?如果不是,請舉例。

  6.C++里面如何聲明const void f(void)函數為C程序中的庫函數?

  7.下列哪兩個(gè)是等同的

  int b;

  A const int* a = &b;

  B const* int a = &b;

  C const int* const a = &b;

  D int const* const a = &b;

  8.內聯(lián)函數在編譯時(shí)是否做參數類(lèi)型檢查?

  void g(base & b){

  b.play;

  }

  void main(){

  son s;

  g(s);

  return;

  }

  華為筆試題

  1.請你分別畫(huà)出OSI的七層網(wǎng)絡(luò )結構圖和TCP/IP的五層結構圖。

  2.請你詳細地解釋一下IP協(xié)議的定義,在哪個(gè)層上面?主要有什么作用?TCP與UDP呢?

  3.請問(wèn)交換機和路由器各自的實(shí)現原理是什么?分別在哪個(gè)層次上面實(shí)現的?

  4.請問(wèn)C++的類(lèi)和C里面的struct有什么區別?

  5.請講一講析構函數和虛函數的用法和作用。

  6.全局變量和局部變量有什么區別?是怎么實(shí)現的?操作系統和編譯器是怎么知道的?

  7.8086是多少位的系統?在數據總線(xiàn)上是怎么實(shí)現的?

  Sony筆試題

  1.完成下列程序

  *

  *.*.

  *..*..*..

  *...*...*...*...

  *....*....*....*....*....

  *.....*.....*.....*.....*.....*.....

  *......*......*......*......*......*......*......

  *.......*.......*.......*.......*.......*.......*.......*.......

  #include

  #define N 8

  int main()

  {

  int i;

  int j;

  int k;

  ---------------------------------------------------------

  | |

  | |

  | |

  return 0;

  }

  2.完成程序,實(shí)現對數組的降序排序

  #include

  void sort( );

  int main()

  {

  int array[]={45,56,76,234,1,34,23,2,3}; //數字任//意給出

  sort( );

  return 0;

  }

  void sort( )

  {

  ____________________________________

  | |

  | |

  |-----------------------------------------------------|

  }

  3.費波那其數列,1,1,2,3,5……編寫(xiě)程序求第十項?梢杂眠f歸,也可以用其他方法,但要說(shuō)明你選擇的理由。

  #include

  int Pheponatch(int);

  int main()

  {

  printf("The 10th is %d",Pheponatch(10));

  return 0;

  }

  int Pheponatch(int N)

  {

  --------------------------------

  | |

  | |

  --------------------------------

  }

  4.下列程序運行時(shí)會(huì )崩潰,請找出錯誤并改正,并且說(shuō)明原因。

  #include

  #include

  typedef struct{

  TNode* left;

  TNode* right;

  int value;

  } TNode;

  TNode* root=NULL;

  void append(int N);

  int main()

  {

  append(63);

  append(45);

  append(32);

  append(77);

  append(96);

  append(21);

  append(17); // Again, 數字任意給出

  }

  void append(int N)

  {

  TNode* NewNode=(TNode *)malloc(sizeof(TNode));

  NewNode->value=N;

  if(root==NULL)

  {

  root=NewNode;

  return;

  }

  else

  {

  TNode* temp;

  temp=root;

  while((N>=temp.value && temp.left!=NULL) || (N

  ))

  {

  while(N>=temp.value && temp.left!=NULL)

  temp=temp.left;

  while(N

  temp=temp.right;

  }

  if(N>=temp.value)

  temp.left=NewNode;

  else

  temp.right=NewNode;

  return;

  }

  }

  MSRA Interview Written Exam(December 2003,Time:2.5 Hours)

  1寫(xiě)出下列算法的時(shí)間復雜度。

  (1)冒泡排序;

  (2)選擇排序;

  (3)插入排序;

  (4)快速排序;

  (5)堆排序;

  (6)歸并排序;

  2寫(xiě)出下列程序在X86上的運行結果。

  struct mybitfields

  {

  unsigned short a : 4;

  unsigned short b : 5;

  unsigned short c : 7;

  }test

  void main(void)

  {

  int i;

  test.a=2;

  test.b=3;

  test.c=0;

  i=*((short *)&test);

  printf("%d\n",i);

  }

  3寫(xiě)出下列程序的運行結果。

  unsigned int i=3;

  cout<

  4寫(xiě)出下列程序所有可能的運行結果。

  int a;

  int b;

  int c;

  void F1()

  {

  b=a*2;

  a=b;

  }

  void F2()

  {

  c=a+1;

  a=c;

  }

  main()

  {

  a=5;

  //Start F1,F2 in parallel

  F1(); F2();

  printf("a=%d\n",a);

  }

  5考察了一個(gè)CharPrev()函數的作用。

  6對 16 Bits colors的處理,要求:

  (1)Byte轉換為RGB時(shí),保留高5、6bits;

  (2)RGB轉換為Byte時(shí),第2、3位置零。

  7一個(gè)鏈表的操作,注意代碼的健壯和安全性。要求:

  (1)增加一個(gè)元素;

  (2)獲得頭元素;

  (3)彈出頭元素(獲得值并刪除)。

  8一個(gè)給定的數值由左邊開(kāi)始升位到右邊第N位,如

  0010<<1 == 0100

  或者

  0001 0011<<4 == 0011 0000

  請用C或者C++或者其他X86上能運行的程序實(shí)現。

  附加題(只有在完成以上題目后,才獲準回答)

  In C++, what does "explicit" mean? what does "protected" mean?

  1。在C++中有沒(méi)有純虛構造函數?

  2。在c++的一個(gè)類(lèi)中聲明一個(gè)static成員變量有沒(méi)有用?

  3。在C++的一個(gè)類(lèi)中聲明一個(gè)靜態(tài)成員函數有沒(méi)有用?

  4。如何實(shí)現一個(gè)非阻塞的socket?

  5。setsockopt, ioctl都可以對socket的屬性進(jìn)行設置,他們有什么不同?

  6。解釋一下進(jìn)程和線(xiàn)程的區別?

  7。解釋一下多播(組播)和廣播的含義?

  8。多播采用的協(xié)議是什么?

  9。在c++中純虛析構函數的作用是什么?請舉例說(shuō)明。

  10。編程,請實(shí)現一個(gè)c語(yǔ)言中類(lèi)似atoi的函數功能(輸入可能包含非數字和空格)


【10道有代表性面試題整理】相關(guān)文章:

戴爾的10道面試題11-18

戴爾12道面試題11-20

經(jīng)典50道面試題目及應答評點(diǎn)02-18

整理渣打電話(huà)面試題庫11-20

酒店的面試題有哪些06-19

職場(chǎng)英語(yǔ):史上最刁鉆的十道面試題11-09

一道微軟公司的經(jīng)典面試題目及答案02-18

根據渣打面經(jīng)整理的分類(lèi)電話(huà)面試題庫11-20

四道題問(wèn)得有講究專(zhuān)家評析江蘇公考面試題02-18

名企代表性考題集粹02-18

激情欧美日韩一区二区,浪货撅高贱屁股求主人调教视频,精品无码成人片一区二区98,国产高清av在线播放,色翁荡息又大又硬又粗视频