早教吧作业答案频道 -->其他-->
《数据结构》求集合{1.3.5.8.9}和集合{2.3.6.8.9.15}的交集,并输出结果
题目详情
《数据结构》求集合{1.3.5.8.9}和集合{2.3.6.8.9.15}的交集,并输出结果
▼优质解答
答案和解析
#include #include struct node { int data; struct node *next; }; typedef struct node *pointer,*lklist; //--------建表------- lklist initiate(lklist head) { head=(pointer)malloc(sizeof(struct node)); head->next=0; return head; } //-------输入表,以32767结尾---------- lklist setup(lklist head) { int x; pointer p=(pointer)malloc(sizeof(struct node)),q; p=head; scanf("%d",&x); while(x!=32767) { q=(pointer)malloc(sizeof(struct node)); q->data=x; p->next=q; p=q; scanf("%d",&x); } p->next=0; return head; } //-------求交集并输出------------ void disqual(lklist la1,lklist la2) { pointer p,q,s; q=la2->next; while(q) { p=la1; while(p->next) { if(p->next->data!=q->data) p=p->next; else { printf("%d ",p->next->data); p=p->next; } } q=q->next; } } void main() { pointer la1=(pointer)malloc(sizeof(struct node)), la2=(pointer)malloc(sizeof(struct node)); printf("请输入la(以32767结尾):\n"); la1=initiate(la1); la1=setup(la1); printf("请输入lb(以32767结尾):\n"); la2=initiate(la2); la2=setup(la2); printf("交集为: "); disqual(la1,la2); printf("\n"); } 学数据结构的时候习惯了用32767作结束表输入,你也可以改成别的你想要的值。
看了 《数据结构》求集合{1.3....的网友还看了以下:
S=(1+1/1*2+(2+1/2*3)+(3+1/3*4)+...+(20+1/20*21)S= 2020-04-27 …
帮我破解下这串数字什么意思9(2)4(3)6(2)2(1)4(3)3(1)4(3)9(1)6(3) 2020-05-17 …
1+2+3+n=2分之1n(n+1),n是正整数,研究1*2+2*3+你(n+1),观察1*2=3 2020-05-20 …
天才进1,1,2,1,2,1,2,3,3,1,3,2,1,2,3,3,1,3,2,1,3,2,3, 2020-05-21 …
49.7-[-23/3/4+(18.7-25.25)]12+1又3/4-8又5/12-6.75-( 2020-06-04 …
怪数学题6=2×3因数是1,2,3,6共有4个12=2×2×3=2²×3¹,因数是1,2,3,4, 2020-06-22 …
1+2+2^2+2^3+2^4+``````+2^201+1/3+1/3^2+1/3^3+1/3^ 2020-07-18 …
已知1^3=1=1/4*1^2*2^2;1^3+2^3=9=1/4*2^2*3^2;1^3+2^3 2020-07-19 …
已知1^3=1=1/4*1^2*2;1^3+2^3=9=1/4*2^2*3^2;1^3+2^3+3 2020-07-19 …
观察下列各式:1^3+2^3=1+8=9,而(1+2)^2=9……观察下列各式:1^3+2^3=1+ 2021-01-01 …