Advertisement
Guest User

Untitled

a guest
Jan 19th, 2018
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int *arra,n,c=0;
  8. cout <<"input the num of index : ";
  9. cin >> n;
  10. arra = new int[n+1];
  11. if(!(arra = new int)){
  12. cout <<"no space found !!!";
  13. }
  14. else {
  15. cout <<"input array : "<<endl;
  16. for(int i = 0;i < n; i++){
  17. cout << i+1 <<" number index : ";
  18. cin>>*(arra+i);
  19. }
  20.  
  21.  
  22.  
  23. for(int i = 0;i < n;i++){
  24.  
  25. if(*(arra+i)<0){
  26.  
  27. for(int j = i;j < n;j++){
  28. *(arra+j)=*(arra+j+1);
  29. }
  30. i--; ///You had a problem here
  31. c++;
  32. }
  33. }
  34.  
  35.  
  36.  
  37.  
  38. n = n-c;
  39. cout<<"c = "<<c<<endl;
  40. cout <<"here is the final array : ";
  41. for(int i = 0;i < n;i++){
  42. cout <<*(arra+i)<<" ";
  43. }
  44. }
  45.  
  46. delete []arra;
  47. return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement