Advertisement
wrench786

Lab task - (Function - 5)

Oct 7th, 2021
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. #define ll long long
  4. #define ull unsigned long long
  5. #define uom unordered_map
  6. #define pb push_back
  7. #define yes cout<<"YES\n"
  8. #define no cout<<"NO\n"
  9.  
  10. #define dot(x) fixed<<setprecision(x)
  11. #define wrench786 ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  12.  
  13. #define PI (acos(-1.0))
  14. #define eps 0.00001
  15. const int LIMIT = 10000*1;
  16. const int mod = 1000000007;
  17. using namespace std;
  18.  
  19.  
  20. int* fun( int *arr,int n,int data)
  21. {
  22. for(int i=0,j=0;i<n;i++,j++){
  23. if(arr[i]==data)j--;
  24. else arr[j]= arr[i];
  25. }
  26.  
  27. return arr;
  28. }
  29.  
  30. int main(){
  31. int n,i,data;
  32. cin>>n;
  33. int arr[n];
  34.  
  35. for(i=0;i<n;i++) cin>>arr[i];
  36.  
  37. cin>>data;
  38.  
  39. int* ptr = fun(arr,n,data);
  40.  
  41. for(i=0;i<n-1;i++){
  42. cout<<*(ptr+i)<<" ";
  43. }
  44. }
  45.  
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement