高分求高手,智力题?

智力题中:
1。一座山,上坡下坡各1km,现在上山速度15km/h,问下山速度要多快才能够平均速度达到

30km/h。
2。一些数字找规律,2,5,14,41,??
3。一个人死了,警察找嫌疑犯,A,B,C三个人。
三个人说:
A:如果是谋杀,一定是B干的
B:如果是谋杀,一定不是我干的
C:如果不是谋杀,一定是自杀
警察:如果上面三个人中只有一个人说谎,那么一定是自杀。
请问那个人死于:谋杀?自杀?意外?
5。一块饼,切一刀最多2块,2刀4块,3刀7块,问7刀最多切多少块?

编程题:
1。计算费波那契数列F_n=F_{n-1}+F_{n-2},用递归和不用递归两种方法。
2。一个单项链表反转。
3。将一个句子的单词反过来(单词原样),比如"i am cheating"变成"cheating am i"。
4。找一个程序的错误,也是关于字符串的。
考一个小时,一张试卷

1.数字找规律
3,10,11,12,13,20,21,22,23,30,31,32,33,100,??

2.乒乓球比赛,每2个人之间比一场,但是有3个人每人比了2场就退出了
总共有50场比赛,问这3个人之间比赛有几场?

3.推销员卖书给年轻太太,答出问题就买书。太太有3个女儿,3个人的年龄乘积是36
年龄之和是邻居的门牌号码,推销员看了门牌号说还是不能确定,还需要一个条件
太太说,大的一个女儿去学钢琴了,推销员立即说出了年龄。问3个女儿年龄各是
多少?仅有一个答案
4.一个花园种花,相邻的不能是同一种,现在有四种植物,问有多少种种法?
花园是一个正六边形,丛中间均分分成6个正三角形。既是6个这样的区域有多少种法?
计算机题4个,研发的做1.2.3,测试的做1.2.4
1.把一个堆栈改为双链表,自己定义具体的东西,用自己熟悉的语言就行
2.一个母兔第四个年头生一个母兔,问第n年有多少母兔?(考试时老师说要求用递归)
3.什么是多态,具体举例解释
4.什么是面向对象,举例说明
1。 2条相交 1个
以后每加一条直线 就和前几条线各有一个交点
所以是1+2+3+4+5+6+7=28个交点

2。 1刀2块
以后每砍一刀 就加(前面的刀数加1)块

做编程给加100分

  1.速度无限大(感觉题有问题)
  设下坡速度x,则:1/x+1/15=2/30 ==> 1/x=0 ==> x=无穷

  2.122
  5=2+3;14=5+3*3;41=14+3*3*3;122=41+3*3*3*3

  3.自杀
  一个默认前提:警察的话应该是正确的。
  如果是谋杀,C的话肯定没问题,但A和B恰好相反,也就是有且只会有一个人说谎,由警察的话得:自杀,与假设矛盾
  如果是意外,A、B的话肯定是正确的,但C的话肯定是错误的,由警察的话得:自杀,又矛盾
  如果是自杀,就不矛盾了

  5.29
  1+1+2+3+4+5+6+7=29.仔细推一推就是这个规律了

  编程题暂时放一放。

  1.101
  规律就是4进制数,遇4进位

  2.1场
  (1)n个的比赛,应该有 n*(n-1)/2 场比赛,这个容易推导
  (2)做假设。如果3个人比赛全部不是3个人之间,则:剩下的人应该踢了50-6=44场。如果6场全部是3个人之间,则:剩下的人踢了50-3=47场。又公式:在44~47之间的只有,n=10,n*(n-1)/2=45符合
  (3)所以3个人之间踢一场,就有4+2/2=5,刚好45+5=50,符合!
  注意理解,2个人之间一场比赛,算一场,但对每个人来说,都踢了一场。

  3. 1、3、12
  首先写出乘积=36,而且计算合:
  1*2*18 21
  1*3*12 16
  1*4*9 14
  2*3*6 11
  只有4组,太太的门牌号肯定是15,所以不能确定是16还是14。因为大女儿学钢琴了,而且只有一个结果,那就选大女儿岁数大的那一组,即第2组为答案

  4. 80
  第四题用程序跑的,发现自己随便推的答案错了。反正是好玩写的,代码献上:
  #include <stdio.h>
  #include <malloc.h>

  void getMemoryInt(int ** pReturn,int num)
  {
  *pReturn=(int *)malloc(num*sizeof(int));
  }

  void initArrInt(int *arr,int count,int value)
  {
  int i;
  for(i=0;i<count;i++)
  arr[i]=value;
  }

  void displayArr(int *arr,int count)/////for test
  {
  int i;
  printf("\nDisplay: \n");
  for(i=0;i<count;i++)
  {
  printf("%9d",arr[i]);
  }
  }

  unsigned long int paintBlock(int icolor,int iblock)
  {
  int i,flag=0;//quit condition
  int flagForSame=0/*check neighbor*/;
  int *block,*colors;
  unsigned long int resultCnt=0;/*result count*/
  int tempCnt=0/*index for block[],from left to right*/,colorCnt=0/*count of color exist*/;

  getMemoryInt(&block,iblock);
  getMemoryInt(&colors,icolor);
  initArrInt(block,iblock,0);

  //displayArr(block,iblock);///////////for test
  //displayArr(colors,icolor);/////////////for test

  while(flag==0)
  {
  initArrInt(colors,icolor,icolor+1);
  flagForSame=0;

  /*block[iblock]++*/
  for(i=0;i<iblock;i++)
  {
  ++block[i];
  if(block[i]==icolor)
  {
  block[i]=0;
  continue;
  }
  else
  break;
  }
  /*reach the max number,cycle ends*/
  if(i==iblock&&block[i-1]==0)
  {
  flag=1;
  }

  /*validate whether neighbor is the same*/
  flagForSame=0;
  for(i=0;i<iblock;i++)
  {
  if(block[i]==block[(i+1)%iblock])
  {
  flagForSame=1;
  break;
  }
  }
  if(flagForSame==1)
  continue;

  /*check whether color count is enough*/
  colors[0]=block[0];
  colorCnt=1;
  tempCnt=1;
  while( tempCnt<iblock && colorCnt<icolor )
  {
  for(i=0;i<colorCnt;i++)
  {
  if(colors[i]==block[tempCnt])
  break;
  }
  if(i==colorCnt)
  {
  ++colorCnt;
  colors[i]=block[tempCnt];
  }
  ++tempCnt;
  }

  if(colorCnt==icolor)
  {
  ++resultCnt;
  //displayArr(block,iblock);
  if(resultCnt>420000000)
  {
  printf("\nToo many result,out of bound!\n");
  return -1;
  }
  }
  }
  return resultCnt/iblock;//考虑对称性
  }

  void main()
  {
  int iB,iC,i;
  unsigned long int result,sum=1;

  printf("Problem source:\n一个花园种花,相邻的不能是同一种,现在有四种植物,问有多少种种法? 花园是一个正六边形,丛中间均分分成6个正三角形。既是6个这样的区域有多少种法?\nIf there is n blocks and m colors and m<n,what is the result?\n");

  printf("Input the block number: ");
  scanf("%d",&iB);
  printf("Input the color number: ");
  scanf("%d",&iC);

  if(iB==iC)
  {
  for(i=1;i<=iB;i++)
  {
  sum*=i;
  }
  result=sum;
  printf("The result: %ld",result);
  }
  else if(iB<iC)
  {
  printf("Color number can't be bigger than block number!\n");
  }
  else
  {
  result=paintBlock(iC,iB);
  if(result==-1)
  {
  printf("Please try again.\n");
  }
  else
  {
  printf("\nThe result: %ld\n",result);
  }
  }
  }

  反转String:
  #include <stdio.h>

  #define SIZE 50

  int getLenth(char arr[])
  {
  int i=0;
  while(arr[i]!='\0')
  {
  ++i;
  }
  return i;
  }

  void initArr(char *a,int n)
  {
  int i;
  for(i=0;i<n;i++)
  a[i]='\0';
  }

  void main()
  {
  char a[SIZE];
  int i,n,temp;

  initArr(a,SIZE);
  gets(a);
  n=getLenth(a);

  if( (n%2)==0 )
  {
  for(i=0;i<n/2;i++)
  {
  temp=a[i];
  a[i]=a[n-1-i];
  a[n-1-i]=temp;
  }
  }else
  {
  for(i=0;i<(n-1)/2;i++)
  {
  temp=a[i];
  a[i]=a[n-1-i];
  a[n-1-i]=temp;
  }
  }
  printf("\nThe result: %s\n",a);
  }

  递归程序:
  #include <stdio.h>
  #include <malloc.h>

  typedef unsigned long int uint32;

  uint32 fibo_dg(int num)//递归
  {
  if(num==1)
  return (uint32)1;
  else if(num==2)
  return (uint32)2;
  else
  return fibo_dg(num-1)+fibo_dg(num-2);
  }

  void getMemoryUint32(uint32 ** pReturn,int num)
  {
  *pReturn=(uint32 *)malloc(num*sizeof(uint32));
  }

  uint32 fibo(int count)//非递归
  {
  int i;
  uint32 *arr;

  getMemoryUint32(&arr,count);
  arr[0]=1;
  arr[1]=2;
  for(i=2;i<count;i++)
  {
  arr[i]=arr[i-1]+arr[i-2];
  }
  return arr[count-1];
  }

  void main()
  {
  int num;
  uint32 sum_dg,sum;

  sum_dg=sum=0;
  printf("Get the F_n number: ");
  scanf("%d",&num);

  sum_dg=fibo_dg(num);
  sum=fibo(num);

  printf("Result\n1)递归:%ld\n2)非递归:%ld\n",sum_dg,sum);
  }

  单链表和堆栈程序(push和pop可以做的更加方便测试的,但没时间不够,就随便写了。还有数据类型应

  该用tpyedef来定义一个的,方便修改存放的数据类型,你可以自己改一改):

  #include <stdio.h>
  #include <stdlib.h>

  typedef struct Node
  {
  int data;
  struct Node *next;
  }*PtrNode;

  void fill_link(PtrNode link,int count)
  {
  PtrNode ptr,temp;
  int i;
  ptr=link;
  for(i=0;i<count-1;i++)
  {
  temp=(PtrNode)malloc(sizeof(struct Node));
  temp->data=i+1;
  temp->next=NULL;
  ptr->next=temp;
  ptr=ptr->next;
  }
  }

  void print_link(PtrNode link)
  {
  PtrNode ptr=link;
  printf("Link:\n");
  while(ptr!=NULL)
  {
  printf("%d\t",ptr->data);
  ptr=ptr->next;
  }
  printf("\n");
  }

  void free_link(PtrNode link)
  {
  PtrNode ptr=link;
  while(ptr->next!=NULL)
  {
  PtrNode temp=ptr->next;
  ptr->next=temp->next;
  free(temp);
  }
  }

  void reverseLink(PtrNode *head)/////////////////////////反转链表
  {
  PtrNode temp1,temp2,temp3;
  temp1=(PtrNode)malloc(sizeof(struct Node));
  temp2=(PtrNode)malloc(sizeof(struct Node));
  temp3=(PtrNode)malloc(sizeof(struct Node));
  if( temp1==NULL||temp2==NULL||temp3==NULL )
  {
  printf("\nError,not enough memory!");
  return;
  }

  temp1=*head;
  temp2=(*head)->next;
  if(temp2==NULL)
  {
  *head=temp2;
  temp2->next=temp1;
  temp1=NULL;
  }
  else
  {
  temp3=temp2->next;
  temp2->next=temp1;
  temp1->next=NULL;
  while(temp3!=NULL)
  {
  temp1=temp2;
  temp2=temp3;
  temp3=temp3->next;
  temp2->next=temp1;
  }
  *head=temp2;
  }
  }

  /*堆栈借用链表来实现*/
  typedef struct stack
  {
  int count;//number of data
  struct Node *next;
  }*Stack;

  Stack st=(Stack)malloc(sizeof(struct stack));//define stack

  void getStack()
  {
  PtrNode head;
  head=(PtrNode)malloc(sizeof(struct Node));
  head->next=NULL;
  head->data=0;
  st->count=0;
  st->next=head;
  }

  void push(int data)
  {
  PtrNode temp=(PtrNode)malloc(sizeof(struct Node));
  temp->next=NULL;
  temp->data=0;

  if(st!=NULL)
  {
  if(st->count!=0)
  {
  temp->data=data;
  temp->next=st->next;
  st->next=temp;
  st->count++;
  }
  else
  {
  st->next->data=data;
  st->count=1;
  }
  }
  }

  int pop()
  {
  int temp_data;
  if(st->count==0)
  {
  printf("No element left.\n");
  return -1;
  }
  else
  {
  PtrNode temp=st->next;
  temp_data=temp->data;
  st->next=st->next->next;
  st->count--;
  free(temp);
  }
  return temp_data;
  }

  int main()
  {
  PtrNode head;
  head=(PtrNode)malloc(sizeof(struct Node));
  head->next=NULL;
  head->data=0;

  fill_link(head,10);//让Link长度为10,加入9个节点
  print_link(head);
  reverseLink(&head);
  print_link(head);
  free_link(head);
  free(head);

  getStack();
  push(100);
  push(10);
  push(20);
  printf("pop: %d\n",pop());
  printf("pop: %d\n",pop());
  printf("pop: %d\n",pop());
  free(st);

  return 0;
  }

  星期天和同学出去玩了...失言了,很抱歉,没做完,不用加分了
温馨提示:答案为网友推荐,仅供参考
相似回答