ADD file via upload

master
pbqa92cj6 3 years ago
parent 9f177b26a4
commit 494a8d1246

@ -0,0 +1,55 @@
//ʹ<><CAB9>ϣ<EFBFBD><CFA3><EFBFBD><EFBFBD><EFBFBD>н<EFBFBD><D0BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#include <stdio.h>
#include <malloc.h>
void shellSort(int *a, int len);
int main(void)
{
int i, len, * a;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ŵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
scanf("%d",&len);
a = (int *)malloc(len * sizeof(int));
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ŵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
for (i = 0; i < len; i++)
{
scanf("%d",&a[i]);
}
shellSort(a, len);
printf("ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>к<EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>\n");
for (i = 0; i < len; i++)
{
printf("%d\t",a[i]);
}
printf("\n");
return 0;
}
void shellSort(int *a, int len)
{
int i, j, k, tmp, gap;
for (gap = len / 2; gap > 0; gap /= 2)
{
for (i = 0; i < gap; ++i)
{
for (j = i + gap; j < len; j += gap)
{
tmp = a[j];
k = j - gap;
while (k >= 0 && a[k] > tmp)
{
a[k + gap] = a[k];
k -= gap;
}
a[k + gap] = tmp;
}
}
}
}
/*<2A><>ʱ<EFBFBD><EFBFBD>Ӷ<EFBFBD>
ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>Ӷ<EFBFBD><EFBF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