设为首页收藏本站

嘻皮客娱乐学习网

 找回密码
 中文注册
搜索
打印 上一主题 下一主题
开启左侧

[面试题库] c/c++某大公司的两道笔试题

[复制链接]
跳转到指定楼层
楼主
发表于 2014-11-30 09:52:50 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
1.一群人围成一圈,123的报数,报3者出列,求最后一个人。
2.利用链表实现将两个有序队列A和B合并到有序队列H中,不准增加其他空间。
请提供全一点的程序

第一题:

// kickout.cpp : Defines the entry point for the console application.
//

#include “stdafx.h”
#include “malloc.h”
#include “stdio.h”

int main()
{
int m,n;
int kickouts = 0;
int *p = NULL;
int i ,j;
i=j=0;
printf(“Please input m,n:”);
scanf(“%d,%d”,&m,&n);

while(ndata < b->data)
{
h->data = a->data;
a = a->next;
}
else if (a->data == b->data)
{
h->data = a->data;
a = a->next;
b = b->next;
}
else
{
h->data = b->data;
b = b->next
}
h = h->next;
}
if (a == NULL)
{
while (b != NULL)
{
h->data = b->data;
h = h->next;
b = b->next;
}
}
else
{
while(a != NULL)
{
h->data = a->next;
h = h->next;
a = a->next;
}
}
回复

使用道具 举报

小黑屋|手机版|嘻皮客网 ( 京ICP备10218169号|京公网安备11010802013797  

GMT+8, 2024-6-14 05:31 , Processed in 0.168939 second(s), 21 queries , Gzip On.

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表