Update 使用插入排序进行升序排列.c

master
pbqa92cj6 3 years ago
parent 85ff106ea5
commit cad0fc2a91

@ -1,4 +1,4 @@
//ʹ<EFBFBD>ò<EFBFBD><EFBFBD><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)
{
@ -17,12 +17,12 @@ int InsertSort(int A[], int n)
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>");
printf("请输入要输入的元素个数:");
scanf("%d",&n);
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD>\n");
printf("\n请输入要排序的序列:\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");
printf("\n使用直接插入排序算法后的结果:\n");
InsertSort(A,n);
for(i=1; i<=n; i++)
printf("%d\t",A[i]);
@ -30,7 +30,7 @@ int main() {
return 0;
}
/*<EFBFBD><EFBFBD>ʱ<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>
/*①时间复杂度为O(n^2)
()
Process exited after 16.06 seconds with return value 0*/

Loading…
Cancel
Save