




已阅读5页,还剩382页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
第5章集合与结构,5.1位运算,5.2集合,5.3结构,5.4结构数组,5.5链表,小结,5.1位运算,计算机的存储器采用二进制表示数据计算机系统的存储器用每8位为1字节编址不同类型的数据由不同字节长度存储每一个数位的取值,只有两个可能值:0或者1位运算能够直接处理数据中每一位的值,为方便起见,本节叙述中用一个字节表示一个正整数,5.1位运算,位运算符则显示结果为,10|29=31,3.按位异或运算,当左右操作数对应位不相同,即当且仅当其中一个为1时,位操作的结果才为1,10000010102900011101,2300010111,若有语句cout10|29=(10|29)endl;则显示结果为,1029=23,4.左移,按右操作数指定位数,将左操作数按位向左移动,腾空数位补0,102000010102,4000101000,若有语句cout102=(102)endl;则显示结果为,102=40,对于一个整数,每左移一位就相当于乘以2(结果不溢出时),4.左移,按右操作数指定位数,将左操作数按位向左移动,腾空数位补0,若有语句cout-102=(-102)endl;则显示结果为,-102000011002,300000011,若有语句cout2=2)2=3,对于一个整数,每右移一位就相当于整除以2,5.右移,按右操作数指定位数,将左操作数按位向右移动,若有语句cout2=2)2=-3,对于一个整数,每右移一位就相当于整除以2,做算术右移时,不会移动符号位,6.按位取反,单目运算。对操作数按位做逻辑非,1000001010,-1111110101,若有语句cout10=(10)b,当一个整数的二进制串中只有一个数位为1时,称为掩码程序中通常借助掩码对数据按位进行测试,掩码,#includeusingnamespacestd;voidbitDisplay(unsignedvalue);voidmain()unsignedx;coutx;bitDisplay(x);/调用函数,以二进制形式输出正整数,【例5-1】按二进制位串形式输出正整数的值。,voidbitDisplay(unsignedvalue)unsignedc;unsignedbitMask=131;/掩码,最高位置1coutvalue=;for(c=1;c=32;c+)cout(value,【例5-1】按二进制位串形式输出正整数的值。,value,bitMask,0,【例5-1】按二进制位串形式输出正整数的值。,voidbitDisplay(unsignedvalue)unsignedc;unsignedbitMask=131;/掩码,最高位置1coutvalue=;for(c=1;c=32;c+)cout(value,value,0,bitMask,【例5-1】按二进制位串形式输出正整数的值。,voidbitDisplay(unsignedvalue)unsignedc;unsignedbitMask=131;/掩码,最高位置1coutvalue=;for(c=1;c=32;c+)cout(value,value,0,bitMask,【例5-1】按二进制位串形式输出正整数的值。,voidbitDisplay(unsignedvalue)unsignedc;unsignedbitMask=131;/掩码,最高位置1coutvalue=;for(c=1;c=32;c+)cout(value,value,0,bitMask,【例5-1】按二进制位串形式输出正整数的值。,voidbitDisplay(unsignedvalue)unsignedc;unsignedbitMask=131;/掩码,最高位置1coutvalue=;for(c=1;c=32;c+)cout(value,value,1,bitMask,【例5-1】按二进制位串形式输出正整数的值。,voidbitDisplay(unsignedvalue)unsignedc;unsignedbitMask=131;/掩码,最高位置1coutvalue=;for(c=1;c=32;c+)cout(value,value,1,bitMask,【例5-1】按二进制位串形式输出正整数的值。,voidbitDisplay(unsignedvalue)unsignedc;unsignedbitMask=131;/掩码,最高位置1coutvalue=;for(c=1;c=32;c+)cout(value,value,0,bitMask,【例5-1】按二进制位串形式输出正整数的值。,voidbitDisplay(unsignedvalue)unsignedc;unsignedbitMask=131;/掩码,最高位置1coutvalue=;for(c=1;c=32;c+)cout(value,value,1,bitMask,【例5-1】按二进制位串形式输出正整数的值。,voidbitDisplay(unsignedvalue)unsignedc;unsignedbitMask=131;/掩码,最高位置1coutvalue=;for(c=1;c=32;c+)coutn2);coutn1n2);coutn1=t“;bitDisplay(n1);,【例5-2】位运算测试,voidbitDisplay(unsignedvalue)unsignedc;unsignedbitMask=131;for(c=1;c=32;c+)coutn2);coutn1=t“;bitDisplay(n1);,【例5-2】位运算测试,voidbitDisplay(unsignedvalue)unsignedc;unsignedbitMask=131;for(c=1;c=32;c+)cout(value,#includeusingnamespacestd;voidmain()inta=123,b=456;couta=atb=bendl;a=ab;couta=abtaendl;a=ab;couta=abtaendl;,【例5-3】数据恢复,#includeusingnamespacestd;voidmain()inta=123,b=456;couta=atb=bendl;a=ab;b=ab;a=ab;couta=atb=bendl;,【例5-4】整变量交换,集合是不能精确定义的基本数学概念。一般认为,当一些事物是可以按照某种性质(属性)分辨,这种事物构成的整体就称为集合。根据集合的属性,可以断定某个特定的事物是否属于这个集合。如果属于,就称它为这个集合的元素。,5.2集合,集合的基本运算,集合通常用大写字母标记,集合元素用小写字母标记若A、B是全集E中的两个集合,x表示元素集合主要运算有:并集AB由A和B中的全部元素组成,集合的基本运算,集合通常用大写字母标记,集合元素用小写字母标记若A、B是全集E中的两个集合,x表示元素集合主要运算有:并集AB由A和B中的全部元素组成交集AB由A和B中的公共的组成,集合的基本运算,集合通常用大写字母标记,集合元素用小写字母标记若A、B是全集E中的两个集合,x表示元素集合主要运算有:并集AB由A和B中的全部元素组成交集AB由A和B中的公共的组成差A-B由属于A但不属于B的元素组成,集合的基本运算,集合通常用大写字母标记,集合元素用小写字母标记若A、B是全集E中的两个集合,x表示元素集合主要运算有:并集AB由A和B中的全部元素组成交集AB由A和B中的公共的组成差A-B由属于A但不属于B的元素组成包含ABA中的每个元素都在B中,称为A被B包含,或B包含A,集合的基本运算,集合通常用大写字母标记,集合元素用小写字母标记若A、B是全集E中的两个集合,x表示元素集合主要运算有:并集AB由A和B中的全部元素组成交集AB由A和B中的公共的组成差A-B由属于A但不属于B的元素组成包含ABA中的每个元素都在B中,称为A被B包含,或B包含A补集A由全集中不在A的元素组成,集合的基本运算,集合通常用大写字母标记,集合元素用小写字母标记若A、B是全集E中的两个集合,x表示元素集合主要运算有:并集AB由A和B中的全部元素组成交集AB由A和B中的公共的组成差A-B由属于A但不属于B的元素组成包含ABA中的每个元素都在B中,称为A被B包含,或B包含A补集A由全集中不在A的元素组成属于xA元素x在A中,集合的基本运算,集合通常用大写字母标记,集合元素用小写字母标记若A、B是全集E中的两个集合,x表示元素集合主要运算有:并集AB由A和B中的全部元素组成交集AB由A和B中的公共的组成差A-B由属于A但不属于B的元素组成包含ABA中的每个元素都在B中,称为A被B包含,或B包含A补集A由全集中不在A的元素组成属于xA元素x在A中空集集合中没有元素,E,集合的基本运算,集合通常用大写字母标记,集合元素用小写字母标记若A、B是全集E中的两个集合,x表示元素集合主要运算有:并集AB由A和B中的全部元素组成交集AB由A和B中的公共的组成差A-B由属于A但不属于B的元素组成包含ABA中的每个元素都在B中,称为A被B包含,或B包含A补集A由全集中不在A的元素组成属于xA元素x在A中空集集合中没有元素,集合运算的实现,数据表示用无符号整数表示全集为32个元素整数集合:1,2,3,4,.,31,32集合变量unsignedA;第i-1位值等于1,表示元素i在集合中第i-1位值等于0,表示元素i不在集合中位序从低位高位从0i-1,集合运算的实现,数据表示,unsignedA;集合二进制位串值十进制值1,3,600100101371,2,5,7010100111012,3,5,7,811010110214,集合运算的实现,基本运算实现,unsignedA,B;/表示2个集合变量unsignedx;/表示集合元素,并集ABA|B,A=1,2,5AB=2,5,7BAB=1,2,5,7A|B=,集合运算的实现,基本运算实现,交集ABA/表示2个集合变量unsignedx;/表示集合元素,集合运算的实现,基本运算实现,差A-BA/表示2个集合变量unsignedx;/表示集合元素,集合运算的实现,基本运算实现,差A-BA/表示2个集合变量unsignedx;/表示集合元素,集合运算的实现,基本运算实现,差A-BA/表示2个集合变量unsignedx;/表示集合元素,集合运算的实现,基本运算实现,unsignedA,B;/表示2个集合变量unsignedx;/表示集合元素,包含ABA|B=B,A=1,2AB=1,2,5,7BAB为真A|B,集合运算的实现,基本运算实现,包含ABA|B=B,A=1,2AB=1,2,5,7BAB为真A|BA|B=B等于true,unsignedA,B;/表示2个集合变量unsignedx;/表示集合元素,A=2,4,5,7Ax=31(x-1),集合运算的实现,基本运算实现,unsignedA,B;/表示2个集合变量unsignedx;/表示集合元素,属于xA1(x-1)/表示2个集合变量unsignedx;/表示集合元素,属于xA1(x-1)/表示2个集合变量unsignedx;/表示集合元素,属于xA1(x-1)/表示2个集合变量unsignedx;/表示集合元素,空集A=A=0,集合运算的实现,基本运算实现,并集ABA|B交集ABA/表示2个集合变量unsignedx;/表示集合元素,/用无符号整数表示132的整数集合/setH.h#includeusingnamespacestd;unsignedputX(unsigned/判空集,【例5-5】集合运算的实现,/steOperate.cpp#includesetH.h“voidsetPut(unsigned,【例5-5】集合运算的实现,unsignedputX(unsigned,【例5-5】集合运算的实现,boolInc(unsignedA,unsignedB)/判蕴含if(A|B)=B)returntrue;returnfalse;boolIn(unsignedS,unsignedx)/判属于xSunsignedbitMask=1;bitMaskx;coutPutxx;if(In(A,x)coutxinAn;elsecoutxx;coutPutxx;if(In(A,x)coutxinAn;elsecoutxx;while(x)putX(S,x);cinx;voidsetDisplay(constsetTypeS)/输出集合S中的全部元素unsignedc,i;unsignedbitMask;if(Null(S)coutn“;return;cout;for(i=0;ix;while(x)putX(S,x);cinx;voidsetDisplay(constsetTypeS)/输出集合S中的全部元素unsignedc,i;unsignedbitMask;if(Null(S)coutn“;return;cout;for(i=0;iN;i+)/处理每个数组元素bitMask=1;/掩码,32位for(c=1;c=32;c+)/按位处理if(Si/刷除最后的逗号,按段测试,元素值,/元素x并入集合SvoidputX(setTypeS,unsignedx)unsignedbitMask=1;bitMask=(x-1)%32);S(x-1)/32|=bitMask;/求并集C=ABvoidCom(setTypeC,constsetTypeA,constsetTypeB)for(inti=0;iN;i+)Ci=Ai|Bi;/求交集C=ABvoidsetInt(setTypeC,constsetTypeA,constsetTypeB)for(inti=0;iN;i+)Ci=Ai,元素在段中位置,元素段,boolInc(constsetTypeA,constsetTypeB)/判蕴含boolt=true;for(inti=0;iN;i+)if(Ai|Bi)!=Bi)t=false;returnt;boolIn(constsetTypeS,unsignedx)/判属于xSunsignedbitMask=1;bitMaskx;if(In(A,x)coutxinAn;elsecoutxnotinAn;,结构由数目固定的成员构成各成员可以具有不同的数据类型一个结构变量在内存占有一片连续的存储空间,5.3结构,结构类型定义形式为:struct标识符类型成员1;类型成员2;类型成员n;,5.3.1定义结构,例:structemployeecharname10;longcode;doublesalary;charaddress50;charphone20;,5.3.1定义结构,例:structemployeecharname10;longcode;doublesalary;charaddress50;charphone20;,可以用不同方法定义一个结构变量,(1)声明类型之后声明变量,employeeworker1,worker2,*Emp;,5.3.1定义结构,例:structemployeecharname10;longcode;doublesalary;charaddress50;charphone20;,可以用不同方法定义一个结构变量,(1)声明类型之后声明变量,worker1,worker2,*Emp;,(2)声明类型的同时声明变量,5.3.1定义结构,例:structemployeecharname10;longcode;doublesalary;charaddress50;charphone20;,可以用不同方法定义一个结构变量,(1)声明类型之后声明变量,worker1,worker2,*Emp;,(2)声明类型的同时声明变量,(3)直接声明结构类型变量,注意此时没有了结构类型标识符,5.3.1定义结构,例:structemployeecharname10;longcode;doublesalary;charaddress50;charphone20;,employeeworker1,worker2,*Emp=,说明,(1)结构变量占有一片连续内存空间,具有结构类型的特征,5.3.1定义结构,说明,(2)一个结构类型的成员可以是另一个已定义的结构类型,structdateintmonth;intday;intyear;structemployeecharname10;datebirthday;longcode;doublesalary;charaddress50;charphone11;worker1,worker2;,例如:为职工结构添加出生日期信息类型和变量声明为:,personson;,5.3.1定义结构,说明,(2)一个结构类型的成员可以是另一个已定义的结构类型,structpersoncharname10;longcode;doublesalary;charaddress50;charphone11;worker1,worker2;,错误不能实现的无穷递归结构,5.3.1定义结构,说明,(3)声明结构类型变量可以同时初始化,structemployeecharname10;longcode;doublesalary;charaddress50;charphone11;worker=WangLi,991083456,1200.5,guangzhou,87111111;,(1)访问结构变量的成员结构变量.成员,点运算符,/例5-7#includeusingnamespacestd;structweather/声明结构类型doubletemp;doublewind;intmain()weathertoday;/声明结构类型变量today.temp=10.5;/对结构变量成员赋值today.wind=3.1;cout“Temp=”today.tempendl;/按成员输出cout“Wind=”today.windname,pp-id,pp-salary,5.1.2访问结构,5.3.2访问结构,(2)用指针访问结构变量的成员结构指针-成员(*结构指针).成员,/例5-8#includeusingnamespacestd;#includestructpersoncharname20;unsignedlongid;doublesalary;intmain()personpr1;person*pp;/定义结构指针pp=,(*pp).name,(*pp).id,(*pp).salary,5.1.2访问结构,5.3.2访问结构,/例5-9#includeusingnamespacestd;structweatherdoubletemp;doublewind;yesterday;intmain()weathertoday;yesterday.temp=10.5;yesterday.wind=3.1;today=yesterday;/结构变量整体赋值cout“Temp=”today.tempendl;cout“Wind=”today.windallonei.salary;coutallonej+1.salary)/结构变量的整体交换temp=allonej;allonej=allonej+1;allonej+1=temp;for(i=0;i6;i+)/输出排序后数据tallonei.idtallonei.salaryallonei.salary;coutallonej+1.salary)/结构变量的整体交换temp=allonej;allonej=allonej+1;allonej+1=temp;for(i=0;i6;i+)/输出排序后数据tallonei.idtallonei.salaryallonei.salary;coutallonej+1.salary)/结构变量的整体交换temp=allonej;allonej=allonej+1;allonej+1=temp;for(i=0;i6;i+)/输出排序后数据tallonei.idtallonei.salaryallonei.salary;coutallonei.salary;coutallonej+1.salary)/结构变量的整体交换temp=allonej;allonej=allonej+1;allonej+1=temp;for(i=0;i6;i+)/输出排序后数据tallonei.idtallonei.salaryallonei.salary;coutallonej+1.salary)/结构变量的整体交换temp=allonej;allonej=allonej+1;allonej+1=temp;for(i=0;i6;i+)/输出排序后数据tallonei.idtallonei.salaryendl;,例5-10对结构数组以某一成员作关键字排序,for(i=0;i6;i+)/输出排序后数据tallonei.idtallonei.salaryallonei.salary;coutallonej+1.salary)/结构变量的整体交换temp=allonej;allonej=allonej+1;allonej+1=temp;for(i=0;i6;i+)/输出排序后数据tallonei.idtallonei.salarydata!=0)if(head=NULL)head=s;elsep-next=s;p=s;s=newnode;cins-data;p-next=NULL;deletes;return(head);,5.3链表,2建立和遍历链表,建立链表的过程:生成头结点;while(未结束)生成新结点;把新结点插入链表;,structnodeintdata;node*next;node*head;node*CreateList()node*s,*p;s=newnode;cins-data;head=NULL;while(s-data!=0)if(head=NULL)head=s;elsep-next=s;p=s;s=newnode;cins-data;p-next=NULL;deletes;return(head);,结构类型,5.3链表,2建立和遍历链表,建立链表的过程:生成头结点;while(未结束)生成新结点;把新结点插入链表;,structnodeintdata;node*next;node*head;node*CreateList()node*s,*p;s=newnode;cins-data;head=NULL;while(s-data!=0)if(head=NULL)head=s;elsep-next=s;p=s;s=newnode;cins-data;p-next=NULL;deletes;return(head);,头指针,5.3链表,2建立和遍历链表,建立链表的过程:生成头结点;while(未结束)生成新结点;把新结点插入链表;,structnodeintdata;node*next;node*head;node*CreateList()node*s,*p;s=newnode;cins-data;head=NULL;while(s-data!=0)if(head=NULL)head=s;elsep-next=s;p=s;s=newnode;cins-data;p-next=NULL;deletes;return(head);,建立链表函数返回头指针,5.3链表,2建立和遍历链表,建立链表的过程:生成头结点;while(未结束)生成新结点;把新结点插入链表;,structnodeintdata;node*next;node*head;node*CreateList()node*s,*p;s=newnode;cins-data;head=NULL;while(s-data!=0)if(head=NULL)head=s;elsep-next=s;p=s;s=newnode;cins-data;p-next=NULL;deletes;return(head);,声明局部量,5.3链表,2建立和遍历链表,建立链表的过程:生成头结点;while(未结束)生成新结点;把新结点插入链表;,structnodeintdata;node*next;node*head;node*CreateList()node*s,*p;s=newnode;cins-data;head=NULL;while(s-data!=0)if(head=NULL)head=s;elsep-next=s;p=s;s=newnode;cins-data;p-next=NULL;deletes;return(head);,建立第一个结点,5.3链表,2建立和遍历链表,建立链表的过程:生成头结点;while(未结束)生成新结点;把新结点插入链表;,structnodeintdata;node*next;node*head;node*CreateList()node*s,*p;s=newnode;cins-data;head=NULL;while(s-data!=0)if(head=NULL)head=s;elsep-next=s;p=s;s=newnode;cins-data;p-next=NULL;deletes;return(head);,链表头指针初始化,5.3链表,2建立和遍历链表,建立链表的过程:生成头结点;while(未结束)生成新结点;把新结点插入链表;,structnodeintdata;node*next;node*head;node*CreateList()node*s,*p;s=newnode;cins-data;head=NULL;while(s-data!=0)if(head=NULL)head=s;elsep-next=s;p=s;s=newnode;cins-data;p-next=NULL;deletes;return(head);,向链表插入新结点,5.3链表,2建立和遍历链表,建立链表的过程:生成头结点;while(未结束)生成新结点;把新结点插入链表;,structnodeintdata;node*next;node*head;node*CreateList()node*s,*p;s=newnode;cins-data;head=NULL;while(s-data!=0)if(head=NULL)head=s;elsep-next=s;p=s;s=newnode;cins-data;p-next=NULL;deletes;return(head);,释放值为0的结点,5.3链表,2建立和遍历链表,建立链表的过程:生成头结点;while(未结束)生成新结点;把新结点插入链表;,structnodeintdata;node*next;node*head;node*CreateList()node*s,*p;s=newnode;cins-data;head=NULL;while(s-data!=0)if(head=NULL)head=s;elsep-next=s;p=s;s=newnode;cins-data;p-next=NULL;deletes;return(head);,返回头指针,5.3链表,s=newnode;cins-data;head=NULL;,5.3链表,s=newnode;cins-data;head=NULL;,5.3链表,s=newnode;cins-data;head=NULL;,s,1,5.3链表,s=newnode;cins-data;head=NULL;,s,1,head,5.3链表,s,1,head,while(s-data!=0)if(head=NULL)head=s;elsep-next=s;p=s;s=newnode;cins-data;,5.3链表,s,1,head,while(s-data!=0)if(head=NULL)head=s;elsep-next=s;p=s;s=newnode;cins-data;,5.3链表,s,1,head,while(s-data!=0)if(head=NULL)head=s;elsep-next=s;p=s;s=newnode;cins-data;,5.3链表,s,1,head,while(s-data!=0)if(head=NULL)head=s;elsep-next=s;p=s;s=newnode;cins-data;,5.3链表,while(s-data!=0)if(head=NULL)head=s;elsep-next=s;p=s;s=newnode;cins-data;,s,1,head,p,5.3链表,while(s-data!=0)if(head=NULL)head=s;elsep-next=s;p=s;s=newnode;cins-data;,s,head,5.3链表,while(s-data!=0)if(head=NULL)head=s;elsep-next=s;p=s;s=newnode;cins-data;,s,head,5.3链表,while(s-data!=0)if(head=NULL)head=s;elsep-next=s;p=s;s=newnode;cins-data;,s,head,3,5.3链表,while(s-data!=0)if(head=NULL)head=s;elsep-next=s;p=s;s=newnode;cins-data;,s,head,3,5.3链表,while(s-data!=0)if(head=NULL)head=s;elsep-next=s;p=s;s=newnode;cins-data;,s,head,3,5.3链表,while(s-data!=0)if(head=NULL)head=s;elsep-next=s;p=s;s=newnode;cins-data;,s,head,3,5.3链表,while(s-data!=0)if(head=NULL)head=s;elsep-next=s;p=s;s=newnode;cins-data;,s,head,p,3,5.3链表,while(s-data!=0)if(head=NULL)head=s;elsep-next=s;p=s;s=newnode;cins-data;,5.3链表,while(s-data!=0)if(head=NULL)head=s;elsep-next=s;p=s;s=newnode;cins-data;,5.3链表,while(s-data!=0)if(head=NULL)head=s;elsep-next=s;p=s;s=newnode;cins-data;,s,5,5.3链表,while(s-data!=0)if(head=NULL)head=s;elsep-next=s;p=s;s=newnode;cins-data;,5.3链表,while(s-data!=0)if(head=NULL)head=s;elsep-next=s;p=s;s=newnode;cins-data;,5.3链表,while(s-data!=0)if(head=NULL)head=s;elsep-next=s;p=s;s=newnode;cins-data;,5.3链表,while(s-data!=0)if(head=NULL)head=s;elsep-next=s;p=s;s=newnode;cins-data;,head,p,3,5.3链表,while(s-data!=0)if(head=NULL)head=s;elsep-next=s;p=s;s=newnode;cins-data;,head,p,3,s,5,5.3链表,while(s-data!=0)if(head=NULL)head=s;elsep-next=s;p=s;s=newnode;cins-data;,head,p,3,s,5,5.3链表,while(s-data!=0)if(head=NULL)head=s;elsep-next=s;p=s;s=newnode;cins-data;,head,p,3,s,5,7,5.3链表,while(s-data!=0)if(head=NULL)head=s;elsep-next=s;p=s;s=newnode;cins-data;,head,p,3,5,s,7,5.3链表,while(s-data!=0)if(head=NULL)head=s;elsep-next=s;p=s;s=newnode;cins-data;,head,p,3,5,s,7,5.3链表,while(s-data!=0)if(head=NULL)head=s;elsep-next=s;p=s;s=newnode;cins-data;,head,p,3,5,s,7,5.3链表,while(s-data!=0)if(head=NULL)head=s;elsep-next=s;p=s;s=newnode;cins-data;,head,p,3,5,s,7,5.3链表,while(s-data!=0)if(head=NULL)head=s;elsep-next=s;p=s;s=newnode;cins-data;,head,p,3,s,5,5.3链表,while(s-data!=0)if(head=NULL)head=s;elsep-next=s;p=s;s=newnode;cins-data;,head,p,3,s,5,5.3链表,while(s-data!=0)if(head=NULL)head=s;elsep-next=s;p=s;s=newnode;cins-data;,head,p,3,s,5,0,5.3链表,while(s-data!=0):,p-next=NULL;deletes;return(head);,head,p,3,s,5,0,5.3链表,while(s-data!=0):,p-next=NULL;deletes;return(head);,head,p,3,s,5,0,5.3链表,while(s-data!=0):,p-next=NULL;deletes;return(head);,head,p,3,s,5,0,5.3链表,while(s-data!=0):,p-next=NULL;deletes;return(head);,head,p,3,s,5,0,5.3链表,while(s-data!=0):,p-next=NULL;deletes;return(head);,head,p,3,5,5.3链表,while(s-data!=0):,p-next=NULL;deletes;return(head);,head,p,3,5,5.3链表,在表头插入结点,3插入结点,s-next=head;head=s;,5.3链表,在表头插入结点,3插入结点,s-next=head;head=s;,5.3链表,在表头插入结点,3插入结点,s-next=head;head=s;,5.3链表,在表头插入结点,3插入结点,s-next=head;head=s;,5.3链表,在表头插入结点,3插入结点,s-next=head;head=s;,5.3链表,在*p之后插入*s,3插入结点,s-next=p-next;p-next=s;,p,5.3链表,在*p之后插入*s,3插入结点,s-next=p-next;p-next=s;,p,5.3链表,在*p之后插入*s,3插入结点,s-next=p-next;p-next=s;,p,5.3链表,在*p之后插入*s,3插入结点,s-next=p-next;p-next=s;,p,5.3链表,在*p之后插入*s,3插入结点,s-next=p-next;p-next=s;,p,5.3链表,在*p之后插入*s,3插入结点,s-next=p-next;p-next=s;,5.3链表,在*p之前插入*s,3插入结点,s-next=p;q-next=s;,p,q,s,5.3链表,方法一,前驱结点指针,在*p之前插入*s,3插入结点,s-next=p;q-next=s;,p,q,s,5.3链表,方法一,在*p之前插入*s,3插入结点,s-next=p;q-next=s;,p,q,s,5.3链表,方法一,在*p之前插入*s,3插入结点,s-next=p;q-next=s;,p,q,s,5.3链表,方法一,在*p之前插入*s,3插入结点,s-next=p;q-next=s;,p,q,s,5.3链表,方法一,在*p之前插入*s,3插入结点,s-next=p-next;p-next=s;,p,5.3链表,方法二,t=p-data;p-data=s-data;s-data=t;,第一步后插,第二步交换数据,在*p之前插入*s,3插入结点,s-next=p-next;p-next=s;,p,5.3链表,方法二,t=p-data;p-data=s-data;s-data=t;,在*p之前插入*s,3插入结点,s-next=p-next;p-next=s;,p,5.3链表,方法二,t=p-data;p-data=s-data;s-data=t;,在*p之前插入*s,3插入结点,s-next=p-next;p-next=s;,p,5.3链表,方法二,t=
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 救生员理论考试题目及答案
- 2025全新高处作业证理论考试题库高空证考试试题(附答案)
- 2025年社会工作者之中级社会工作法规与政策自我提分评估附答案
- 2025年全国初中生思想品德学业测评模拟试题(附答案)
- 2025发展对象考试试题库及参考答案
- 2025经济合同管理制度
- 2025年职业技校汽修专业:汽车维修高级技师资格证考试题库附参考答案【培优b卷】
- 2025年统计学试题库(附答案)
- 护理学上岗考试题及答案
- 电叉车工考试题库及答案
- 下半年中小学教师资格笔试考试题库带答案2025
- 酒吧店长聘用协议书
- 2025-2030中国钽电解电容器市场营运格局分析与全景深度解析报告
- 晋副主任护师的述职报告
- 广西田林八渡金矿 资源储量核实报告
- 《消化性溃疡诊疗》课件
- CISA国际注册信息系统审计师认证备考试题库(600题)
- iso28000-2022供应链安全管理手册程序文件表单一整套
- DB21∕T 3149-2019 玉米秸秆还田机械化作业技术规程
- 报价函(工程项目招标文件资料)
- 【退休欢送会】课件
评论
0/150
提交评论