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(n<1)
{
printf("n doen't less 0 , retry n:");
scanf("%d",&n);
}
p=(int*)malloc(m*sizeof(int));
for(i=0;i
{
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;
}
}