Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

Commit

Permalink
✅ Change-newSizeArray
Browse files Browse the repository at this point in the history
  • Loading branch information
NTGNguyen committed Oct 25, 2023
1 parent f02245c commit d69e77e
Showing 1 changed file with 19 additions and 21 deletions.
40 changes: 19 additions & 21 deletions Problem_006/6_008.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,32 @@ using namespace std;

int main()
{
int n;
cin >> n;
int a[500];
for (int i = 0; i < n; i++)
cin >> a[i];
int Number_Erase;
cin >> Number_Erase;
int dem = 0;
for (int i = 0; i < n; i++)
int size;
cin >> size;

int arr[500];
for (int i = 0; i < size; i++)
{
if (a[i] == Number_Erase)
dem++;
cin >> arr[i];
}
for (int i = 0; i < n; i++)

int num;
cin >> num;

int newSize = 0;
for (int i = 0; i < size; i++)
{
if (a[i] == Number_Erase)
if (arr[i] != num)
{
for (int j = i; j < n; j++)
{
a[j] = a[j + 1];
}
arr[newSize] = arr[i];
newSize++;
}
}
if (n == dem)
return 0;
for (int i = 0; i < n - dem; i++)

for (int i = 0; i < newSize; i++)
{
cout << a[i] << " ";
cout << arr[i] << " ";
}

return 0;
}

0 comments on commit d69e77e

Please sign in to comment.