全文预览

C语言答案华科

上传者:徐小白 |  格式:pdf  |  页数:64 |  大小:2639KB

文档介绍
he document was created with Spire.PDF for .NET.\rint temp;\rfor(i=0;i<n-l;i++)\r(\rm = i;\rfor(j=i+l;j<n;j++)\r(\rif(flag == 1)\r(\rif(p[j]>p[m])\rm =j;\r)\relse\r(\rif(p[j]<p[m])\rm =j;\r)\r)\rif(m!=i)\rtemp = p[i];.\rp[i] = p[m];\rp[m] = temp;\r)\r)\r)\rmain()\r(\rint a[20];\rint n,i;\rint flag;\rprintf("please enter n(<20):");\rscanf("%d",&n);\rgetchar();\rprintf("please enter array a:");\rfor(i=0;i<n;i++)\rscanf("%d",&a[i]);\rgetchar();\rprintf("please enter paixu flag:\n");.\rprintf("\tl:degression\n");\rprintf("\tO:increasion\t:");\rscanf("%d",&flag);\rpaixu(a,n,flag);\rprintf("array a is:");\rfor(i=0;i<n;i++)\rprintf("%4d",a[i]);\rprintf("\n\n");

收藏

分享

举报
下载此文档