资源描述:
《平时练习之简单链表》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、作素操素元-八^&一-进苫购元詈购豎您现新已购入印入專岀win奎-RI.kkLL各20104109034T0025320907价3584.0.1590.91134021编号1001200383215980409028203333632155771100^^冃¥镜刀套包束笔名生牙毛杀齧蕭卫化瑰作素操素元的-兀单进苫购元詈购豎想您现新已购入印入專岀tin主月
2、匚{.1.;.了入解所要插入的商品信息及想要插入的位置编号召灯231154•“1功,新的购物单如下:主□编号价格231154111001302200350083218215
3、9801450409010342820121鑿冃镜名台生牙毛妆卫化套包束笔作素操素一-八®f行素进蕩购;您现新已购入印入專岀主后」>».」;.02W位素L7除々館删品品口駅择商商商购选入入入入略.11仔435801590号“编23201410903002320907存鑿冃畫刀套包束笔名台生牙齧輪作素操素一-八®f行素进蕩购;詈购豎您现新已购入印入專岀主为21编息」作式•方02杳一品品口駅择商商商购选入入入入7—」.?I.亠.••一冃.••'一冃.•'一冃/•一BU主后」3.LL素-素元•元单项28迸蕩购元这功刀您现新已购^<
4、印入靠岀21找亠杳一请123455Otyekyna#include#include#includeusingnamespacestd;constintsize=10;structProduct{charname[l()l;intnumber;doublevalue;};structLinearList{Product*element;intlength;intmaxsize;};Productp[size]={{”卫生纸“,1001,3.02},{“牙膏”,2003,5
5、.00},{”毛巾“,8321,8.21},{”书n,5980,14.50},{”化妆镜“,4090,10.34},{“小刀",2820,1.21},{“枕套“,3333,35.00},{”钱包“,6321,49.99},{”玫瑰花束”,5577,100.00},{“钢笔°,1100,29.73}};voidCreatLinearList(LinearList&L,intMaxListSize){L.maxsizc=MaxListSizc;L.element=newProduct[L.maxsize];L.length=0;
6、}voidprint(Productx){cout«setw(8)«x.name«setw(8)«x>number«setiosflags(ios::fixed)«setw(8)«setprecision(2)«x.value«endl;}voidOutputLinearList(LinearList&L){«endl;inti;coutvv"*************************"cout«setw(8)«n名称"«setw(8)«"编号”«setw(8)«"价格"«endl;for(i=0;i<10;i++)
7、print(L.clcmcnt[i]);«endl;coutvv"*************************”boolGetElemLinearList(LinearList&L,intk,Product&result){if(kLlength)returnfalse;result=L.element[k-1];returntrue;}intSearchByNumbcr(LinearList&L,intnum)//通过编号找到元素位置{inti;for(i=0;i8、lement[i].number==num)returni;}return-1;}intSearchByValue(LinearList&L,doubleval)//通过价格找到元素位置{inti;for(i=0;i9、t[i].namc,na)==O)returni;}return-1;)intScarchLincarList(LincarList&L,Product&x){for(inti=0;i