标签:style blog http color io os ar for div
1 # include<iostream> 2 # include<cstdio> 3 using namespace std; 4 void Insert(int *_piArr,int len) 5 { 6 int i = 1; 7 for(;i < len;i++) 8 { 9 int j = i; 10 int x = _piArr[i]; 11 while((j > 0)&&(_piArr[j-1]>x))//前一个大于后一个 12 { 13 _piArr[j] = _piArr[j-1]; 14 j--;//向后移动 15 } 16 _piArr[j] = x;// 17 } 18 } 19 int main() 20 { 21 int a[100],n; 22 cin>>n; 23 for(int i = 0;i < n;i++) 24 { 25 cin>>a[i]; 26 } 27 Insert(a,n); 28 for(int i = 0;i < n;i++) 29 { 30 cout<<a[i]<<" "; 31 } 32 }
标签:style blog http color io os ar for div
原文地址:http://www.cnblogs.com/sxmcACM/p/3978168.html