下载
加入VIP
  • 专属下载特权
  • 现金文档折扣购买
  • VIP免费专区
  • 千万文档免费下载

上传资料

关闭

关闭

关闭

封号提示

内容

首页 C语言选择排序源码指针练习

C语言选择排序源码指针练习.doc

C语言选择排序源码指针练习

钱小荣
2017-09-30 0人阅读 举报 0 0 暂无简介

简介:本文档为《C语言选择排序源码指针练习doc》,可适用于综合领域

C语言选择排序源码指针练习#include<stdioh>voidswap(int*a,int*b){intzz=*a*a=*b*b=z}ñÈÊý×éÖеÄ×îóÖµvoidgetMaxValue(){chara,*p,**q,**maxinti=for(i=i<i){pi=ai}for(i=i<i){scanf("c",ai)}a=''max=pq=pfor(i=i<i,q){if(**max<**q){max=q}}printf("sn",a)printf("cn",**max)}voidtestArray(char*a){inti=intlength=sizeof(a)sizeof(char)printf("sn",a)printf("dn",length)for(i=i<lengthi){printf("cn",ai)}}ÑÔñÅÅÐòÎvoidtestSelectSort(inta,intn){inti=intmin=inttimes=intj=printf("ÅÅÐòÇn")for(i=i<ni){printf("dn",ai)}for(i=i<ni){for(j=ij<nj){if(aj<ai){min=j}else{min=i}if(min!=i){timesprintf("µÄÔªËØÊÇ:ad=d,ad=dn",i,ai,min,amin)swap(ai,amin)}}printf("ÅÅÍêÐòºóad=dn",i,ai)}printf("×ÜÁËdÎÅÅÐòºón",times)i=for(i=i<ni){printf("dn",ai)}}ÓźóµÄÑÔñÅÅÐòÖÎvoidtestSelectSortPerfect(inta,intn){intmin=inti=inttimes=intj=printf("ÅÅÐòÇn")for(i=i<ni){printf("dn",ai)}for(i=i<ni){min=ifor(j=ij<nj){if(aj<amin){min=j}}if(min!=i){timesprintf("µÄÔªËØÊÇ:ad=d,ad=dn",i,ai,min,amin)swap(ai,amin)}printf("ÅÅÍêÐòºóad=dn",i,ai)}printf("×ÜÁËdÎÅÅÐòºón",times)i=for(i=i<ni){printf("dn",ai)}}þÎÊý×éÖÕë×öΪºÊýÎÊývoidtestdoubledimensionalarray(int(*p),inttcol,inttrow,int*sum,int*row,int*col){intm=inti=intj=intmax=**pintn*sum=for(m=m<trowm){for(n=n<tcoln){printf("d,",*(*(pm)n))}}for(i=i<trowi){for(j=j<tcolj){*sum=*sum*(*(pi)j)if(*(*(pi)j)>max){max=*(*(pi)j)*col=i*row=j}}}}ÔÚ×ÖûaÖÐéÕÒÁíÒö×ÖûÈböÏÖµÄÎÖúÍÎÊývoidqueryOutStr(char*mainStr,char*containStr,int*times,int*positions){intcount=intstartPos=intendPos=int*pos=positionsintisContain=intposition=char*mainPointer=mainStrchar*containPointer=containStrcontainPointer=containStrwhile(*mainPointer!=''){isContain=while(*containPointer!=''){printf("ÈϵÄÊÇcºÍcn",*containPointer,*mainPointer)if(*containPointer!=*mainPointer||*mainPointer==''){isContain=endPosmainPointerbreak}containPointermainPointerendPos}containPointer=containStrprintf("n")if(isContain==){count*times*pos=positionposprintf("µÚdöÎÖêʵµÚdöÎÖÃÏàµÈn",startPos,endPos)ÏàµÈÒÔºóÒÏòºóÒÆÁËÒÎ}startPos=endPos}printf("×ÜÏàµÈÎÊýΪ:dn",count)}voidmain(){chara="abcdbbbcdc"charb="cd"inttimes=intposqueryOutStr(a,b,times,pos)}*þÖÕëÖÏòÊý×éintrow,col,sum,i,j,(*p)inta={,,,,,,,,,,,,,,,}printf("Ô,Êý×éºn")for(i=i<i){for(j=j<j){printf("d,",*(*(ai)j))}printf("n")}p=atestdoubledimensionalarray(p,,,sum,row,col)printf("×îóÖµµÄÐÐÁкÅÊÇ:d,dn",row,col)printf("ºÍÊÇ:dn",sum)**ÅÅÐòËãâÊÔÊýÝinta={,,,,,}int*p=atestSelectSortPerfect(p,)printf("ÊǵØÖÁËÂðáûÈçϺn")for(inti=i<i){printf("dn",ai)}***scanf("d",x)printf("dn",*p)

用户评价(0)

关闭

新课改视野下建构高中语文教学实验成果报告(32KB)

抱歉,积分不足下载失败,请稍后再试!

提示

试读已结束,如需要继续阅读或者下载,敬请购买!

文档小程序码

使用微信“扫一扫”扫码寻找文档

1

打开微信

2

扫描小程序码

3

发布寻找信息

4

等待寻找结果

我知道了
评分:

/10

C语言选择排序源码指针练习

VIP

在线
客服

免费
邮箱

爱问共享资料服务号

扫描关注领取更多福利