删除顺序表中指定区间的数据
1 #include2 #include 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< <<" ";32 } 33 return 0;34 }