SWUST OJ(1103)

删除顺序表中指定区间的数据

 1 #include <iostream>
 2 #include <cstdlib>
 3 using namespace std;
 4 
 5 int main()
 6 {
 7     int *data, n, x, y;
 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     cin>>x>>y;
18     int k = 0;
19 
20     for (int i = 0; i < n; ++i)
21     {
22         if(data[i] <= y && data[i] >= x)
23         {
24             continue;
25         }
26         data[k++] = data[i];
27     }
28 
29     for (int i = 0; i < k; ++i)
30     {
31         cout<<data[i]<<" ";
32     }    
33     return 0;
34 }

 

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