为什么排序算法看的人这么少{:10_269:} 超凡天赐 发表于 2017-3-9 16:14
为什么排序算法看的人这么少
步伐不一样 {:5_94:} {:10_324:} {:5_103:} #include <stdio.h>
void shell_sort(int array[], int length);
void shell_sort(int array[], int length)
{
int i, j, step, temp;
for (step = length / 2; step > 0; step /= 2)
{
for (i = step; i < length; i++)
{
temp = array;
for (j = i - step; j >= 0 && array > temp; j -= step)
{
array = array;
}
array = temp;
}
}
}
int main(void)
{
int array[] = {73, 108, 111, 118, 101, 70, 105, 115, 104, 67, 46, 99, 111, 109};
int i, length;
length = sizeof(array) / sizeof(array);
shell_sort(array, length);
printf("排序后的结果是:");
for (i = 0; i < length; i++)
{
printf("%d ", array);
}
putchar('\n');
return 0;
} #include<stdio.h>
void shell(int a[],int len)
{
int i,j,tem,step;
for(step = len/2; step > 0; step /= 2)
{
for(i = step;i < len;i++)
{
tem = a;
for(j = i - step;j >= 0 && a > tem;j -= step)
{
a = a;
}
a = tem;
}
}
}
int main(void)
{
int i,len;
int array[] = {73, 108, 111, 118, 101, 70, 105, 115, 104, 67, 46, 99, 111, 109};
len = sizeof(array)/sizeof(array);
printf("希尔排序前的数组:");
for(i = 0;i < len;i++)
{
printf("%d ",array);
}
putchar('\n');
shell(array,len);
printf("希尔排序后的数组:");
for(i = 0;i < len;i++)
{
printf("%d ",array);
}
putchar('\n');
return 0;
} #include<stdio.h>
void shell(int a[],int len)
{
int i,j,tem,step;
for(step = len/2; step > 0; step /= 2)
{
for(i = step;i < len;i++)
{
tem = a;
for(j = i - step;j >= 0 && a > tem;j -= step)
{
a = a;
}
a = tem;
}
}
}
int main(void)
{
int i,len;
int array[] = {73, 108, 111, 118, 101, 70, 105, 115, 104, 67, 46, 99, 111, 109};
len = sizeof(array)/sizeof(array);
printf("希尔排序前的数组:");
for(i = 0;i < len;i++)
{
printf("%d ",array);
}
putchar('\n');
shell(array,len);
printf("希尔排序后的数组:");
for(i = 0;i < len;i++)
{
printf("%d ",array);
}
putchar('\n');
return 0;
} #include<stdio.h>
void shell(int a[],int len)
{
int i,j,tem,step;
for(step = len/2; step > 0; step /= 2)
{
for(i = step;i < len;i++)
{
tem = a;
for(j = i - step;j >= 0 && a > tem;j -= step)
{
a = a;
}
a = tem;
}
}
}
int main(void)
{
int i,len;
int array[] = {73, 108, 111, 118, 101, 70, 105, 115, 104, 67, 46, 99, 111, 109};
len = sizeof(array)/sizeof(array);
printf("希尔排序前的数组:");
for(i = 0;i < len;i++)
{
printf("%d ",array);
}
putchar('\n');
shell(array,len);
printf("希尔排序后的数组:");
for(i = 0;i < len;i++)
{
printf("%d ",array);
}
putchar('\n');
return 0;
} {:10_250:}
好好学习才能天天向上! 自己要实现是真的费劲{:10_266:} 很多人觉得nan
页:
[1]