您当前所在位置:
88好学网范文常识招聘应聘笔试亚马逊在线笔试题目» 正文

亚马逊在线笔试题目

[10-20 23:53:58]   来源:http://www.88haoxue.com  笔试   阅读:680

概要:char* calculateOperationSequence(int * originalArray, int * resultArray, int length){if (NULL == originalArray || NULL == resultArray || length <= 0)return NULL;//使用一个栈模拟入栈和出栈操作就ok了。string str;stack st;int i = 0;int j = 0;st.push(originalArray[i]);char tmp[5] = "\0";str.append("push");sprintf(tmp, "%d", originalArray[i]);str.append(tmp);str.append("|");i++;while (!st.empty()){if (j < length && st.top() == resultArray[j]){str.append("p

亚马逊在线笔试题目,标签:笔试大全,http://www.88haoxue.com

  char* calculateOperationSequence(int * originalArray, int * resultArray, int length)

  {

  if (NULL == originalArray || NULL == resultArray || length <= 0)

  return NULL;

  //使用一个栈模拟入栈和出栈操作就ok了。

  string str;

  stack st;

  int i = 0;

  int j = 0;

  st.push(originalArray[i]);

  char tmp[5] = "\0";

  str.append("push");

  sprintf(tmp, "%d", originalArray[i]);

  str.append(tmp);

  str.append("|");

  i++;

  while (!st.empty())

  {

  if (j < length && st.top() == resultArray[j])

  {

  str.append("pop");

  sprintf(tmp, "%d", resultArray[j]);

  str.append(tmp);

  str.append("|");

  st.pop();

  j++;

  if (i < length)

  {

  st.push(originalArray[i]);

  str.append("push");

  sprintf(tmp, "%d", originalArray[i]);

  str.append(tmp);

  str.append("|");

  i++;

  }

  }

  else

  {

  if (i < length)

  {

  st.push(originalArray[i]);

  str.append("push");

  sprintf(tmp, "%d", originalArray[i]);

  str.append(tmp);

  str.append("|");

  i++;

  }

  else

  break;

  }

  }

  if (!st.empty())

  return NULL;

  char *p = (char *)malloc(1 + str.length());

  if (NULL != p)

  {

  strcpy(p, str.c_str());

  p[str.length() - 1] = '\0';

  return p;

  }

  return NULL;

  }

上一页  [1] [2] [3] 


Tag:笔试笔试大全招聘应聘 - 笔试

上一篇:iphone笔试题目

》《亚马逊在线笔试题目》相关文章