标签:pre amp sql color clu return col for tmp
#include<iostream> #include<stdio.h> #include<string.h> #include<algorithm> using namespace std; struct sqlist{ int *elem; int length; }; void creat(sqlist &a){ a.elem=(int *)malloc(sizeof(int)); int n,tmp; scanf("%d",&n); for (int i=1;i<=n;i++){ scanf("%d",&tmp); a.elem[i]=tmp; } a.length=n; return ; } void insert_sort(sqlist a){ int i,j; for (i=2;i<=a.length;i++){ if (a.elem[i-1]>a.elem[i]){ a.elem[0]=a.elem[i]; a.elem[i]=a.elem[i-1]; for (j=i-2;a.elem[j]>=a.elem[0];j--){ a.elem[j+1]=a.elem[j]; } a.elem[j+1]=a.elem[0]; } } } void print(sqlist a){ for (int i=1;i<=a.length;i++){ printf("%d ",a.elem[i]); } } int main(){ sqlist a; creat(a); insert_sort(a); print(a); return 0; }
标签:pre amp sql color clu return col for tmp
原文地址:https://www.cnblogs.com/bluefly-hrbust/p/10189810.html