折半查找法:针对有序数组 #include #include #define M 10void main(){ static int a[M]={-12,0,6,16,23,56,80,100,110,115}; int n,low,mid,high,found; low=0; high=M-1; found=0; printf("Input a number to be search... Read More
此例中使用两重循环来实现排序。但是值得注意的是以上程序执行时元素的交换并不都是必须的。 #include #include #define N 10void main(){ int i,j,t; int a[N]; clrscr(); for(i=0;i#include #define N 10void main(){ int i,j,t,k; int a[N]; clrscr();... Read More
如果右上角元素大于左下角元素,然后交换。输出经过处理后的右上角元素(含对角线) #include #include #define M 4#define N 4void main(){ clrscr(); int i,j; int a[M][N]={{13,22,33,44},{5,63,7,8},{91,10,11,12},{13,14,15,16}}; for(i=0;ia[j][i]) a[... Read More
#include #include #define M 4#define N 4void main(){ clrscr(); int i,k; int a[M][N]={{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16}}; int b[M][N]; for(i=0;i#include #define M 4#define N 4void main(){ ... Read More