Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- void Fast_IO(){
- ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
- // freopen("filename.in", "r", stdin);
- // freopen("filename.txt", "w", stdout);
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
- #endif
- }
- int main ()
- {
- Fast_IO();
- int n, i, j, k = 0; // k is intial size of array B
- cout << "Enter size of array : ";
- cin >> n;
- int A[n], B[n];
- cout << "Enter elements of array : ";
- for (i = 0; i < n; i++)
- cin >> A[i]; // input element in array
- for (i = 0; i < n; i++) // loop for traverse the array
- {
- for (j = 0; j < k; j++) // loop for checking the element is present in B array or not
- {
- if (A[i] == B[j]) // if present then break the loop
- break;
- }
- if (j == k) // if not present in B array then insert it
- {
- B[k] = A[i]; // insert element in B array
- k++; // increment the size of B array
- }
- }
- cout << "Repeated elements after deletion : ";
- for (i = 0; i < k; i++)
- cout << B[i] << " "; // print the array B
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement