1 #include<iostream>
2 #include<vector>
3 using namespace std;
4 int main() {
5 vector<int> arr;
6 int i;
7 cout<<"please input the num:"<<endl;
8 while(cin>>i)
9 arr.push_back(i);
10 cout<<"the num you have input is :"<<endl;
11 for(int j=0;j<arr.size();j++)
12 cout<<arr[j]<<" ";
13 cout<<endl<<"-------------------"<<endl;
14 for(int l=1;l<arr.size();l++) {
15 int m,key=arr[l];
16 m=l-1;
17 while(m>=0&&arr[m]>key) {
18 arr[m+1]=arr[m];
19 m=m-1;
20 }
21 arr[m+1]=key;
22 }
23 for(int n=0;n<arr.size();n++)
24 cout<<arr[n]<<" ";
25 cout<<endl;
26 return 0;
27 }