资源描述:
《c语言编程集 数据结构 顺序表 点链表 数制转换 矩阵转置.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、#include"stdio.h"#include"malloc.h"/*typedefstruct{int*elem;intlength;intlistsize;}sqlist;*/voidcompare(int*p,int*q,inta,intb){int*elem,*fadd;int*pl=p+a;int*ql=q+b;elem=(int*)malloc(sizeof(int));fadd=elem;while((p<=pl)&&(q<=ql)){if(*p<=*q){*elem=*p;elem++;p+
2、+;}else{*elem=*q;q++;elem++;}}while(p<=pl){*elem++=*p++;}while(q<=ql){*elem++=*q++;}while(fadd<=elem-1){printf("%d",*fadd);fadd++;}}main(){inta[3]={1,2,3};intb[3]={1,2,3};compare(a,b,2,2);}#include"stdio.h"#include"malloc.h"#definesizep3typedefstruct{int*e
3、lem;intlength;intlistsize;}sqlist;sqlistscant(sqlist*p){printf("请输入串长度:");scanf("%d",&(*p).length);//scanf("%d",&(*p).listsize);(*p).elem=(int*)malloc(sizeof(int));return*p;}sqlistshuru(sqlist*m){int*p=(*m).elem;while(p<=(*m).elem+(*m).length-1){scanf("%d"
4、,p);p++;}p=(*m).elem;/*while(p<=(*m).elem+(*m).length){printf("%d",*p);p++;}*/}voidcompare(sqlist*p,sqlist*q){sqlistr;int*fadd;int*pl=(*p).elem+(*p).length-1;int*ql=(*q).elem+(*q).length-1;r.length=(*p).length+(*q).length;r.elem=(int*)malloc(sizeof(int));f
5、add=r.elem;//printf("%d",r.elem);while((*p).elem<=pl&&(*q).elem<=ql){if(*((*p).elem)<=*((*q).elem)){*(r.elem)=*((*p).elem);r.elem++;(*p).elem++;}else{*(r.elem)++=*((*q).elem)++;}}while((*p).elem<=pl){*(r.elem)++=*((*p).elem)++;}while((*q).elem<=ql){*(r.elem)
6、++=*((*q).elem)++;}//printf("%d",*fadd+1,fadd+r.length-1);//printf("%d",fadd+r.length-1);printf("排序数组为:");while(fadd<=r.elem-1){printf("%-3d",*fadd);fadd=fadd+1;}printf("");}main(){sqlistp,q,r;scant(&p);shuru(&p);scant(&q);shuru(&q);compare(&p,&q);}#incl
7、ude"stdio.h"#include"malloc.h"#definemax101typedefstructlnode{intdata;inti,j;}syz;typedefstruct{introw,col,tn;syzdata[max];}link;voidcreat(link*k){ints,p,q,r;printf("请输入矩阵的行数和列数:");scanf("%d",&(*k).row);scanf("%d",&(*k).col);printf("请输入非零元的个数:");scanf("%
8、d",&(*k).tn);printf("请输入一个三元组:");for(s=0;s<=(*k).tn-1;s++){scanf("%d",&r);(*k).data[s].i=r;scanf("%d",&q);(*k).data[s].j=q;scanf("%d",&p);(*k).data[s].data=p;}printf("");}voidtransform(link*