当前位置:七七学习网文档大全求职指南求职笔试面试笔试题目部分IT公司笔试算法题» 正文

部分IT公司笔试算法题

[10-10 21:21:19]   来源:http://www.77xue.com  笔试题目   阅读:8903
概要:node *head = create(6);print(head);head = reverse(head, NULL);print(head);}18、编码实现字符串转整型的函数(实现函数atoi的功能),据说是神州数码笔试题。如将字符串 ”+123”123, ”-0123”-123, “123CS45”123, “123.45CS”123, “CS123.45”0#include "stdafx.h"int str2int(const char *str) { // 字符串转整型函数int i=0, sign=1, value = 0;if(str==NULL) return NULL; // 空串直接返回 NULLif(str[0]=='-' ||
部分IT公司笔试算法题,标签:驾照笔试题目,腾讯笔试题目,http://www.77xue.com

  node *head = create(6);

  print(head);

  head = reverse(head, NULL);

  print(head);

  }

  18、编码实现字符串转整型的函数(实现函数atoi的功能),据说是神州数码笔试题。如将字符串 ”+123”123, ”-0123”-123, “123CS45”123, “123.45CS”123, “CS123.45”0

  #include "stdafx.h"

  int str2int(const char *str) { // 字符串转整型函数

  int i=0, sign=1, value = 0;

  if(str==NULL) return NULL; // 空串直接返回 NULL

  if(str[0]=='-' || str[0]=='+') { // 判断是否存在符号位

  i = 1;

  sign = (str[0]=='-' ? -1 : 1);

  }

  for(; str>='0' && str<='9'; i++) // 如果是数字,则继续转换

  value = value * 10 + (str - '0');

  return sign * value;

  }

  int main(int argc, char *argv[]) {

  char *str = "-123.45CS67";

  int val = str2int(str);

  printf("str=%s\tval=%d\n", str, val);

  }

  19、歌德巴赫猜想。任何一个偶数都可以分解为两个素数之和。(其实这是个C二级考试的模拟试题)

  #include "stdafx.h"

  #include "math.h"

  int main(int argc, char* argv[]) {

  int Even=78, Prime1, Prime2, Tmp1, Tmp2;

  for(Prime1=3; Prime1<=Even/2; Prime1+=2) {

  for(Tmp1=2,Tmp2=sqrt(float(Prime1)); Tmp1<=Tmp2 && Prime1%Tmp1 != 0; Tmp1++);

  if(Tmp1<=Tmp2) continue;

  Prime2 = Even-Prime1;

  for(Tmp1=2,Tmp2=sqrt(float(Prime2)); Tmp1<=Tmp2 && Prime2%Tmp1 != 0; Tmp1++);

  if(Tmp1<=Tmp2) continue;

  printf("%d=%d+%d\n", Even, Prime1, Prime2);

  }

  }

  20、快速排序(东软喜欢考类似的算法填空题,又如堆排序的算法等)

  #include "stdafx.h"

  #define N 10

  int part(int list[], int low, int high) { // 一趟排序,返回分割点位置

  int tmp = list[low];

  while(low

  while(low=tmp) --high;

  list[low] = list[high];

  while(low

  list[high] = list[low];

  }

  list[low] = tmp;

  return low;

  }

  void QSort(int list[], int low, int high) { // 应用递归进行快速排序

  if(low

  int mid = part(list, low, high);

  QSort(list, low, mid-1);

  QSort(list, mid+1, high);

  }

  }

  void show(int list[], int n) { // 输出列表中元素

  for(int i=0; i

  printf("%d ", list);

  printf("\n");

  }

  int main(int argc, char* argv[]) {

  int list[N] = {23, 65, 26, 1, 6, 89, 3, 12, 33, 8};

  show(list, N); // 输出排序前序列

  QSort(list, 0, N-1); // 快速排序

  show(list, N); // 输出排序后序列

  }

  21、20xx年11月23日慧通笔试题:写一函数判断某个整数是否为回文数,如12321为回文数。可以用判断入栈和出栈是否相同来实现(略微复杂些),这里是将整数逆序后形成另一整数,判断两个整数是否相等来实现的。

上一页  [1] [2] [3] [4] [5] [6] [7] [8] [9]  下一页


Tag:笔试题目驾照笔试题目,腾讯笔试题目求职指南 - 求职笔试面试 - 笔试题目

《部分IT公司笔试算法题》相关文章

联系我们 | 网站地图 | 范文大全 | 管理知识 | 教学教育 | 作文大全 | 语句好词
Copyright http://www.77xue.com--(七七学习网) All Right Reserved.
1 2 3 4 5 6 7 8 9 10