Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void NhapMang(int A[], int &n, int &x)
- {
- cin >> n >> x;
- for (int i=0; i<n; i++)
- cin >> A[i];
- }
- void DeleteX(int A[], int &n, int vtri)
- {
- for (int i=vtri; i<n-1; i++)
- A[i] = A[i+1];
- n = n-1; // Giam so luong phan tu cua mang
- }
- void Process(int A[], int &n, int x)
- {
- int i =0;
- while (i<n)
- {
- if (A[i]<x)
- {
- DeleteX(A,n,i);
- i--; //Vi tri moi cap nhat sau khi xoa A[i]
- }
- i++;
- }
- }
- void XuatMang (int A[], int n)
- {
- for (int i=0; i<n; i++)
- cout << A[i] << " ";
- }
- int main()
- {
- int A[1000];
- int x, n;
- NhapMang(A,n,x);
- Process(A,n,x);
- XuatMang(A,n);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement