请C语言版数据结构高手帮帮忙!

完成如下五题,其中顺序存储结构两题,链式存储结构两题,数据结构应用一题。题目如下:1)编写一算法实现:设顺序表L中的数据元素递增有序,删除表中所有值大于k1且小于k2的元... 完成如下五题,其中顺序存储结构两题,链式存储结构两题,数据结构应用一题。
题目如下:
1) 编写一算法实现:设顺序表L中的数据元素递增有序,删除表中所有值大于k1且小于k2的元素(k1<= k2)。要求尽量减少移动元素的次数。
2) 编写一算法实现对于键盘输入的任意一个非负的十进制整数,打印输出与其等值的八进制数。
3) 求集合的交集:已知两个单链表A和B分别表示两个集合,其头指针分别为ha和hb,其元素类型为int且递增有序。设计一算法实现求A和B的交集C,要求C以递增单链表形式存储。
4) 假设以一维数组来存储循环队列的元素,同时设变量rear和qlen分别指示循环队列中队尾元素位置和队列元素个数。试给出此循环队列的判队空、判队满函数,并写出相应的入队和出队算法。
5) 设计一个算法,将带头结点的单链表中有重复值的结点删除(如有多个结点的值相同,保留第一个结点,将其余的结点删除)
解题格式如下:
(1)解题思路(文字描述)
(2)算法函数
(3)主程序测试(两三个测试用例验证算法正确性)
(4)测试结果样例(截图)

说明:题目量有点大,哪位高手帮我解答的话,除了现在悬赏的100分,每题加100分!我打算把自己的财富值全部付出!也就是说,要是五题都解答了,就再加500分!(一次性可能加不了这么多分,我会另提几个问题,然后直接采纳,保证把500分加满!!!请回答者留下邮箱,以便于我另提几个问题后,将问题的网址发给解答者!)
期限:最好在十天内给予解答!
我的邮箱:dyy@dyond.com。 每做完一题,就请发到我的邮箱,我就会提一个问题,给予100分奖励!直至500加满!等5题做完之后,这个问题的100分也赠给回答者!加上系统每题送20分,所以,回答者最少可以得到:720分!如果大家嫌少,我还可以再加分!我还有1000多分的经验值,可以再加!宗旨,我知道这个工作很难,真心希望大家帮帮忙!!非常感谢!!
展开
 我来答
he702477275
2010-12-19 · 超过34用户采纳过TA的回答
知道答主
回答量:147
采纳率:0%
帮助的人:121万
展开全部
第一题:
#include<iostream.h>
struct list
{
int num;
struct list *next;
}head={0,0};
void push(struct list *head,int num)
{
struct list *p=head;
while(p->next&&p->next->num<num)
{
p=p->next;
};
struct list *p1=new list;
p1->num=num;
p1->next=p->next;
p->next=p1;
}
void pop(struct list *head,int num1,int num2)//num1<num2
{
struct list *p=head,*q,*q1;
while(p->next&&p->next->num<=num1)
{
p=p->next;
//cout<<endl<<p->num;
};
q=p;
p=p->next;
while (p&&p->num<num2)
{
q1=p;
p=p->next;
delete q1;
}
q->next=p;
}
void print(struct list *head)
{
struct list *p=head->next;
while (p)
{
cout<<p->num<<ends;
p=p->next;
}
}
void main()
{
push(&head,1);
push(&head,4);
push(&head,6);
push(&head,2);
push(&head,3);
push(&head,7);
push(&head,-1);
print(&head);
cout<<endl;
pop(&head,1,6);
print(&head);
}
第二题:
#include<iostream.h>
void change(unsigned int num,char str[])
{
unsigned int temp;
int i=0;
char te[100];
do
{
//temp=num/8;
te[i++]=num%8+48;
num=num/8;
} while(num);
for (int j=0;j<i;j++)
{
str[j]=te[i-j-1];
}
str[j]=0;

}
void main()
{
unsigned int num;
char str[100];
cin>>num;
change(num,str);
cout<<str;
}
第三题:
#include<iostream.h>
struct list
{
int num;
struct list *next;
}head1={0,0},head2={0,0},head3={0,0};
void push(struct list *head,int num)
{
struct list *p=head;
while(p->next&&p->next->num<num)
{
p=p->next;
};
struct list *p1=new list;
p1->num=num;
p1->next=p->next;
p->next=p1;
}
void print(struct list *head)
{
struct list *p=head->next;
while (p)
{
cout<<p->num<<ends;
p=p->next;
}
}
void hebing(struct list *head1,struct list *head2,struct list *head3)
{
struct list *p1=head1->next,*p2=head2->next,*p3=head3,*p4;
while (p1||p2)
{
if (p1&&p2&&p1->num==p2->num)
{
p4=p1;
p1=p1->next;
p2=p2->next;
}
else if (p1&&!p2||((p1&&p2)&&p1->num<p2->num))
{
p4=p1;
p1=p1->next;
}
else
{
p4=p2;
p2=p2->next;
}
struct list *p=new struct list;
p->num=p4->num;
p->next=p3->next;
p3->next=p;
p3=p3->next;
}

}
void main()
{
push(&head1,1);
push(&head1,4);
push(&head1,6);
push(&head1,2);
push(&head1,3);
push(&head1,7);
push(&head1,-1);

push(&head2,3);
push(&head2,1);
push(&head2,9);
push(&head2,-2);
push(&head2,-3);
push(&head2,7);
push(&head2,-1);
print(&head1);
cout<<endl;
print(&head2);
cout<<endl;
hebing(&head1,&head2,&head3);
print(&head3);
}

//最近要考试,有空把后面几个写给你。
//妄我专门腾出那么多时间帮你写。竟不加分。
1144794789
2010-12-17
知道答主
回答量:43
采纳率:0%
帮助的人:20.5万
展开全部
第二题: 把M改成8就行了 这也是我们的一道作业 是转换成任意进制的
#include<stdio.h>
#include<stdlib.h>

typedef int Status; //status 是函数的类型,其值是函数的结果状态代码
#define TURE 1
#define OK 1
#define ERROR 0
#define INFEASIBLE -1
#define OVERFLOW -2 //函数的结果状态代码的宏定义

#define STACK_INIT_SIZE 100 //存储空间初始分配量
#define INCREMENT 10 //存储空间分配增量

typedef struct {
int * b; //在栈结构之前和销毁之后,b的值均为NULL
int * t; //栈顶指针
int stacksize; //当前分配的存储空间
}SqStack;

//--------------------------基本操作的算法描述---------------------------------------

Status InitStack(SqStack &S)
{ //构造一个空栈S
S.b=(int*)malloc(STACK_INIT_SIZE * sizeof(int));
if(!S.b)exit(OVERFLOW); //存储分配失败
S.t=S.b;
S.stacksize=STACK_INIT_SIZE;
return OK;
}//Initstack
//Status DestroyStack(SqStack &S){ //销毁栈S
// while(S.b!=S.t){
// free(--S.t)
// }
// return OK;
//}//Destroystack
Status Push(SqStack &S,SElemType e){ //插入e为新的栈顶元素
if(S.t-S.b>=S.stacksize){ //栈满追加存储空间
S.b=(SElemType*) realloc (S.b,(S.stacksize+INCREMENT)* sizeof(SElemTyoe));
if(!S.b)exit(OVERFLOW); //存储分配失败
S.t=S.b+S.stacksize;
S.Stacksize+=INCREMENT;
}//if
*S.t++=e;
return OK;
}//Push
Status StackEmpty(SqStack S){ //若栈S为空,则返回TURE,否则返回FALSE。
if(S.b==S.t)return OK;
else return FALSE;
}//StackEmpty

Status Pop(SqStack &S,SElemType &e){ //若S不空,则删除S的栈顶元素,用e其值 并返回OK;否则返回FALSE
if(S.b==S.t)return ERROR;
e=*--S.t;
return OK;
}//Pop
void conversion(SqStack &S,SElemType N,SElemTyoe M) { //把 N 转换成M 进制,并存入S中;
while(N){
Push(S,N%M);
N=N/M;
}
}//conversion

//------------------------------主函数部分--------------------------------------------

void main(){
SqStack S;
int n,m,e;
char p;
InitStack(S);
do{
printf("请输入一非负十进制整数和要转换的进制数(用空格隔开)");
scanf("%d %d",&n,&m);
conversion(S,n,m); //调用conversion 进行转换
printf("%d转换成%d进制为:\n",n,m);
while(!StackEmpty(S)){ //输出结果
Pop(S,e);
if(e>=10)printf("%x",e);
else printf("%d",e);
}//while
//StackEmpey(S); //销毁栈S
printf("如果想要继续请按下Y键,否则请按任意键:"); //做个循环——再次转换
scanf("%c",&p);
}while(p=='Y'||p=='y');

}
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
wenz01
2010-12-17 · TA获得超过672个赞
知道小有建树答主
回答量:226
采纳率:0%
帮助的人:226万
展开全部
这种题目好好看看课本就可以做出来的。还是自己学吧。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式