| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 743 人关注过本帖
标题:两个线性表LA和LB,今要将LB中不同于LA的元素插入LA,请问要怎么做,谢谢!
只看楼主 加入收藏
feelings010
Rank: 1
等 级:新手上路
帖 子:63
专家分:0
注 册:2007-4-20
收藏
 问题点数:0 回复次数:3 
两个线性表LA和LB,今要将LB中不同于LA的元素插入LA,请问要怎么做,谢谢!
#include<stdio.h>
#include<stdlib.h>
#define MAXSIZE 20
typedef int ElemType;
typedef struct
{
ElemType a[MAXSIZE];
int length;
}SqList;
SqList a,b;
void creat_list(SqList *L);
void out_list(SqList L);
void union(List *La,List Lb);
void main(){
int k;
do{
printf("\n\n");
printf("\n 1,建立线性表");
printf(" \n 2.LB与LA不同的元素插入LA中.");
printf("\n 3.结束程序.");
printf("\n===============================");
printf("\n请输入你的选择(1.2,3)");
scanf("%d",k);
switch(k)
{
case 1:{creat_list(&a);out_list(a);
creat_list(&b);out_list(b);
}break;
case 2:{union(&a,b);out_list(a);
}break;
}
}
while(k!=3);
printf("\n 再见!");
printf("\n 打回车键,返回。");ch=getch();
}
void creat_list(SqList *L)
{int i;
printf("\n n=?");scanf("%d",&L->length);
for(i=0;i<L->length;i++){
printf("\n data %d=?",i);
scanf("%d",&(L->a[i]));
}
}
void out_list(SqList L)
{
int i;char ch;
printf("\n");
for(i=0;i<=L.length-1;i++)printf("%10d",L.a[i]);
printf("\n\n 打回车键,继续。");ch=getch();
}
void union(List *La,List Lb){
La-len=ListLength(La);Lb_len=ListLength(Lb);
for(i+1;i<=Lb.len;i++){
GetElem(Lb,i<e);
if(!LocageElem(La,e,equal)) ListInsert(La,++La_len,e);
}
}

请各位朋友帮下忙,帮我看下这个程序错在哪里?怎么会不可以运行,谢谢!
搜索更多相关主题的帖子: include 线性表 元素 
2007-05-04 16:24
feelings010
Rank: 1
等 级:新手上路
帖 子:63
专家分:0
注 册:2007-4-20
收藏
得分:0 
怎么还没有人帮忙啊?
2007-05-04 19:32
ggggcui
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2007-5-4
收藏
得分:0 
看一下数据结构教材,里面就有例程
2007-05-04 21:23
nuciewth
Rank: 14Rank: 14Rank: 14Rank: 14
来 自:我爱龙龙
等 级:贵宾
威 望:104
帖 子:9786
专家分:208
注 册:2006-5-23
收藏
得分:0 
两个线性表LA和LB,今要将LB中不同于LA的元素插入LA,
对lb中每一个元素在LA中搜索,如果不在LA中,就挂在LA后,LA的长度增加,以次循环.直到结束.

倚天照海花无数,流水高山心自知。
2007-05-08 23:19
快速回复:两个线性表LA和LB,今要将LB中不同于LA的元素插入LA,请问要怎么做,谢 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019420 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved