【正文】
{mid=(h+t)/2。 /*輸入要查找的數(shù)據(jù)*/ h=0。 scanf(%d,amp。a[i])。in。n)。 printf(please enter the number of data:(20) )。 int point。 else printf(The data is not in the array!)。 break。in。k)。 printf(please enter the number to be located:)。i++) scanf(%d,amp。 /*輸入原始數(shù)據(jù)的個數(shù)*/ for(i=0。 scanf(%d,amp。 clrscr()。(順序查找、折半查找)順序查找程序:include include void main( ){int a[20],i,n,k。i++) printf(%5d ,a[i])。for(i=0。 } else {printf(%d is not exist!\n,n)。i9。printf(output the array after earse:\n)。i++) a[i]=a[i+1]。} if(point!=1) /*n存在于數(shù)組中*/{for(i=point。i++) if(a[i]==n) {point=i。 /*保存應(yīng)該刪除的位置下標(biāo)*/ for(i=0。n)。 point printf(enter the number to be earsed: \n)。 clrscr()。 /* 輸出插入后的一維數(shù)組序列 */} 數(shù)組的元素的刪除:從數(shù)組中刪除指定的元素n。in+1。 printf(The array after insert is:\n)。 a[point]=k。ipoint。 break。in。 /*輸入要插入的數(shù)據(jù)*/523 56 65 78 895923 56 59 65 78 89i=2 224。 scanf(%d,amp。i++) printf(%5d,a[i])。 for(i=0。a[i])。in。n)。 printf(\nplease enter the number of data:(20) )。 int point。 /* 輸出排序后的一維數(shù)組序列 */} 假如數(shù)組a中的n個數(shù)是有序的,請將輸入的數(shù)k插入到a中,要求插入后依然保持有序。in。} }printf(\n output the sorted array\n)。a[j]=a[j+1]。j=k1。i) {k=i。 /* 輸出原始的一維數(shù)組序列 */ for(i=n1。in。 printf(\n output the original array\n)。i++) scanf(%d,amp。 for(i=0。 scanf(%d,amp。clrscr()。 /* 輸出排序后的一維數(shù)組序列 */}方法三:冒泡法include include void main( ){int i,j,k,n,a[100]。in。} } printf(\n output the sorted array\n)。a[i]=a[p]。j++) if(a[j]a[p]) p=j。 /*假定第i趟中最小數(shù)的位置是i*/ for(j=i+1。in1。i++) printf(%5d,a[i])。 for(i=0。a[i])。in。n)。 printf(enter the number:\n)。int temp。i++) printf(%5d,a[i])。 for(i=0。a[j]=temp。j++) if(a[i]a[j]) {temp=a[i]。i++)