博彦公司2013招聘开发笔试题目

15 篇文章 0 订阅
2 篇文章 0 订阅

通过这次的笔试,感觉题目都很简单,但当下来对程序实现的时候,发现好多地方考虑的不够周到,下面将题目自己总结了一下,有什么问题希望大家提出来,一起学习!!

1、链表两两逆置(不用指针的倒换,直接用倒数据就可以)

#include "stdafx.h"

#include <iostream>

using namespace std;

typedef struct node

{

         int data;

         struct node *next;

}node;

node *create()

{

         int n=6;

         node *head=(node *)malloc(sizeof(node)),*p,*s;

         head->data=0;

         p=head;

         for(int i=1;i<n;i++)

         {

                   s=(node *)malloc(sizeof(node));

                   s->data=i;

                   p->next=s;

                   p=p->next;

         }

         p->next=NULL;

         return head;

}

void print(node *head)

{

         int n=6;

         node *p;

         p=head;

         while(p)

         {

                   cout<<p->data<<" ";

                   p=p->next;

         }

}

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

{

         node *head=create(),*p,*q;

         p=head;

         if(!p)

                   return 0;

         q=p->next;

         while(p&&q)

         {

                   //a=a^b;

                   //b=a^b;

                   //a=a^b;

                   p->data=p->data^q->data;

                   q->data=p->data^q->data;

                   p->data=p->data^q->data;

                   p=p->next->next;

                   if(p)

                            q=q->next->next;

                   else break;

         }

         print(head);

         cout<<endl;

         system("pause");

         return 0;

}

2、一个有序数组和一个数,数组中的两个数的和等于该数,求这个两个数,时间复杂试为O(n)

#include "stdafx.h"

#include <iostream>

using namespace std;

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

{

         int a[]={1,2,4,7,11,15};

         int m=15;

         int n=6;

         int begin=0,end=n-1;;

         while(begin<end)

         {

                   if(a[begin]+a[end]<m)

                   {

                            begin++;

                   }

                   else if(a[begin]+a[end]>m)

                   {

                            end--;

                   }

                   else

                   {

                            cout<<a[begin]<<" "<<a[end];

                            break;

                   }

         }

         cout<<endl;

         system("pause");

         return 0;

}

3I am a student.输出student. a am I(标点不动)

#include "stdafx.h"

#include <iostream>

using namespace std;

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

{

         //̨²°??¤?¤¡§ê?䨮¨®¨°¡ãê?®?Ì????¤?º??¡ê

         /*

         char c[]="I am a student.";

         //char c[]="I come from tianjin.";

         int len=strlen(c);

         int begin=len,end=0;

         for(int i=len-1;i>=0;i--)

         {

                   if(c[i]==' ')

                   {

                            end=begin;

                            begin=i;

                            for(int j=begin+1;j<=end-1;j++)

                            {

                                     cout<<c[j];

                            }

                            cout<<" ";

                   }

         }

         begin=0;

         for(int k=0;k<len;k++)

         {

                   if(c[k]==' ')

                   {

                            end=k;

                            break;

                   }

         }

         for(int m=begin;m<end;m++)

         {

                   cout<<c[m];

         }

         cout<<endl;

         system("pause");

         return 0;*/

         //̨²t?¤?¤¡§ê?¨¨¨?¨¬Ì1?ê?¨?¨®ä¨®¡ãª¨´¨®ê?®?Ì???¨²Ì1?

         char c[]="I am a student.";

         //char c[]="I come from tianjin.";

         int len=strlen(c);

         int begin=0,end=len-1,tmp;

         while(begin<end)

         {

                   tmp=c[begin];

                   c[begin]=c[end];

                   c[end]=tmp;

                   begin++;

                   end--;

         }

         begin=0;

         end=-2;

         int b,e;

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

         {

                   if(c[i]==' ')

                   {

                            begin=end+2;

                            end=i-1;

                            b=begin;

                            e=end;

                            while(b<e)

                            {

                                     tmp=c[b];

                                     c[b]=c[e];

                                     c[e]=tmp;

                                     b++;

                                     e--;

                            }

                   }

         }

 

         for(int m=0;m<len;m++)

         {

                   cout<<c[m];

         }

         cout<<endl;

         system("pause");

         return 0;

}

4、约瑟夫环,最后一个输出是几,环中n个数,从0~n-1,数到第m个数删除

#include "stdafx.h"

#include <iostream>

using namespace std;

typedef struct node

{

         int data;

         struct node *next;

}node;

node *create(int n)

{

         node *head=(node *)malloc(sizeof(node)),*p,*s;

         head->data=0;

         p=head;

         for(int i=1;i<n;i++)

         {

                   s=(node *)malloc(sizeof(node));

                   s->data=i;

                   p->next=s;

                   p=p->next;

         }

         p->next=head;

         return head;

}

void print(node *head,int n)

{

         node *p;

         cout<<head->data<<" ";

         p=head->next;

         while(p!=head)

         {

                   cout<<p->data<<" ";

                   p=p->next;

         }

         cout<<endl;

}

 

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

{

         int n=5,m=2,count=1;

         print(create(n),n);

         node *head=create(n),*p=head,*q;

         while(p->next!=p)

         {

                   while(count!=m)

                   {

                            q=p;

                            p=p->next;

                            count++;

                   }

                   count=1;

                   cout<<p->data<<" ";

                   q->next=q->next->next;

                   p=q->next;

         }

         cout<<p->data;

         cout<<endl;

         system("pause");

         return 0;

}

5Customer(ID,Name)

Order(ID,CustId,Revenue)

选出CustomerRevenuer的和

use DBName

--使用SUM函数,Order与数据库关键字冲突,要使用[]

--连接查询

--此外不能只写Customer.IDselect中出现的字段(除聚合函数),必须出现在group by中,group by中出现的字段应大于等于select后的字段(除聚合函数)

select Customer.Name,SUM([Order].Revenue)

from Customer,[Order]

where Customer.ID=[Order].CustId

group by Customer.Name

6、翻译

data form:数据表单

list:列表

optional method:可选择的方法

enter information:输入信息

field:字段名

data menu:数据菜单

在一个列表中,表单提供一种输入信息的可选择的方法。一旦字段名被输入,你可以使用数据菜单来访问数据表单。甚至起初你不用选择列表的范围,只要当数据表单打开时,活动的单元格在列表范围内,电子表格将自动定位列表。

随着你向表单中增加新的记录,列表的范围将使用新的行不断的更新,电子表格自动增加列表的范围。

7

As the development of science and technology, more and more people use the Internet;they enjoy downloading various kinds of materials.Someone likes to download free music especially, they think that downloading free music not only enriches our lives, but also is beneficial to music industry, because it contributes to increasing the music popularity.

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值