请问大佬,这个冒泡排序可以改成其他的排序方法吗?
程序代码:
#include<stdio.h> #include<stdlib.h> int main() { int *p,n,i,j,end,num,temp1,temp2; scanf("%d",&n); p = (int *) malloc((n+1)*sizeof(int)) ; for(i=0;i<n;i++) { scanf("%d",p+i); } scanf("%d",&num); if(num>=p[n-1]){ p[n] = num; } else { for(i=0;i<n+1;i++) { if(num<p[i]) { temp1 = p[i]; p[i] = num; for(j=i+1;j<n+1;j++) { temp2 = p[j]; p[j] = temp1; temp1 = temp2; } break; } } } for(i=0;i<n+1;i++) { printf("%d,",p[i]); } return 0; }