Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int *arra,n,c=0;
- cout <<"input the num of index : ";
- cin >> n;
- arra = new int[n+1];
- if(!(arra = new int)){
- cout <<"no space found !!!";
- }
- else {
- cout <<"input array : "<<endl;
- for(int i = 0;i < n; i++){
- cout << i+1 <<" number index : ";
- cin>>*(arra+i);
- }
- for(int i = 0;i < n;i++){
- if(*(arra+i)<0){
- for(int j = i;j < n;j++){
- *(arra+j)=*(arra+j+1);
- }
- i--; ///You had a problem here
- c++;
- }
- }
- n = n-c;
- cout<<"c = "<<c<<endl;
- cout <<"here is the final array : ";
- for(int i = 0;i < n;i++){
- cout <<*(arra+i)<<" ";
- }
- }
- delete []arra;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement