You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
//ʹ<>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
int InsertSort(int A[], int n)
|
|
|
|
|
{
|
|
|
|
|
int i,j;
|
|
|
|
|
for(i=2; i<=n; i++)
|
|
|
|
|
{
|
|
|
|
|
A[0]=A[i];
|
|
|
|
|
for(j=i-1; A[0]<A[j]; j--)
|
|
|
|
|
{
|
|
|
|
|
A[j+1]=A[j];
|
|
|
|
|
}
|
|
|
|
|
A[j+1]=A[0];
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
|
int A[1024],n,i;
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD>ظ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
scanf("%d",&n);
|
|
|
|
|
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD>\n");
|
|
|
|
|
for (i=1; i<=n; i++)
|
|
|
|
|
scanf("%d",&A[i]);
|
|
|
|
|
printf("\nʹ<EFBFBD><EFBFBD>ֱ<EFBFBD>Ӳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㷨<EFBFBD><EFBFBD>Ľ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
InsertSort(A,n);
|
|
|
|
|
for(i=1; i<=n; i++)
|
|
|
|
|
printf("%d\t",A[i]);
|
|
|
|
|
printf("\n");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*<2A><>ʱ<EFBFBD>临<EFBFBD>Ӷ<EFBFBD>ΪO(n^2)
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD><EFBFBD>洢<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD>洢(<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD><EFBFBD>洢)
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㷨
|
|
|
|
|
Process exited after 16.06 seconds with return value 0*/
|