SWUST OJ(1102)

顺序表上数据的划分问题的实现

 1 #include <iostream>
 2 #include <cstdlib>
 3 using namespace std;
 4 
 5 int main()
 6 {
 7     int *data, n;
 8     cin>>n;
 9 
10     data = (int*)malloc(n*sizeof(int));
11 
12     for (int i = 0; i < n; ++i)
13     {
14         cin>>data[i];
15     }
16 
17     for (int i = n-1; i >= 0; --i)
18     {
19         if (data[i] <= data[0])
20         {
21             cout<<data[i]<<" ";
22         }
23     }
24 
25     for (int i = 0; i < n; ++i)
26     {
27         if (data[i]>data[0])
28         {
29             cout<<data[i]<<" ";
30         }
31     }
32     return 0;
33 }

 

posted @ 2019-04-09 17:32  Ghost4C  阅读(303)  评论(0编辑  收藏  举报