现在的位置: 首页 > 综合 > 正文

阿尔卡特笔试题目之三

2013年09月01日 ⁄ 综合 ⁄ 共 2022字 ⁄ 字号 评论关闭

  1.自己定义数据结构,写出程序:在一个单向链表中,往I位置插入一个节点。

Typedef  struct  node{
        datatype  data;
        
struct   node  *next;
}
listnode;
typedef 
struct slist {
        
int count;
        listnode
* m_pNodeHead;
}
slist;

void  insertnode(linklist  head,datetype  x,int  i)
{
       listnode  
* p,*q;
      p
=getnode(head,i-1);
      
if(p==NULL)
           error(〝position  error〞);
      q
=(listnode *)malloc(sizeof(listnode));
      q–
>data=x;
      q–
>next=p–next;
      p–
>next=q;
}

 

  2.自己定义数据结构,写出程序:二叉树的前序遍历。

typedef BiTNode* SElemType;
typedef 
struct{
    SElemType 
*base;
    SElemType 
*top;
    
int stacksize;
}
SqStack;
void preorder(BiTree T)
{    
    SqStack S;      BiTree P
=T;
    InitStack(S);    Push(S,NULL);
    
while (P)
    
{     printf("%c",P->data);
           
if (P->rchild)
                 Push(S,P
->rchild);
           
if (P->lchild)
                P
=P->lchild;
           
else Pop(S,P);
    }

}

 

  3.不允许使用系统时间,写出一个随机数生成函数。

static   unsigned   long   seed   =   1;  
   
  #define   A   48271L  
  #define   M   2147483647L  
  #define   Q   (M   /   A)  
  #define   R   (M   %   A)  
   
  double  
  Random(void)  
  {  
          long   TmpSeed;  
          TmpSeed   =   A   *   (   Seed   %   Q)   -   R   *   (Seed   /   Q);  
          if(TmpSeed>=0)  
                  Seed   =   TmpSeed;  
            else  
                  Seed   =   TmpSeed   +   M;  
            return   (double)   Seed   /   M;  
  }  
  void   Initialize(unsigned   long   InitVal)  
  {  
                    Seed   =   InitVal;  
  }  

  这次是连环游戏,每一题的答案将在下一题中用到。

  1、{first 10-digit prime found in consecutive digits e}.com.

  e中出现的连续的第一个10个数字组成的质数。

  2、7427466391.com

  Congratulations,Youve made it to level 2. Go to www.Linux.org and enter

Bobsyouruncle as the login and the answer to this equation as the password.

  f(1)=7182818284

  f(2)=8182845904

  f(3)=8747135266

  f(4)=7427466391

  f(5)=__________

  update:提示:f(1)到f(4)是e中连续的10个数字满足总和等于49的前4个,f(5)当然

是让你搜索第5个咯,编个小程序吧。

  答案:5966290435

  3、www.Linux.org

  4、www.google.com/labjobs/

  via:

  Google recruits eggheads with mystery billboard

  Mysterious Billboard May Be Google Recruitment Ad

  Myserious billboard

  Google is behind mystery geek trap

  写一句俳句来描述搜索流量季节性预测的可能方法。

  用三种颜色为一个二十面体涂颜色,每面都要覆盖,你能够用多少种不同的涂法?你

将选择哪三种颜色?

  这是一个我们故意留给你你空白,请填充一些你喜欢的东西。

抱歉!评论已关闭.