Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int main()
- {
- int A[] = { -5,1,-6,2,-7,3 };
- int n = sizeof( A ) / sizeof( int );
- std::vector< int > B;
- int* pIter = &A[ 0 ];
- int* pLast = &A[ n-1 ];
- int nMax = 0, nCur = 0;
- while( pIter != pLast )
- {
- pIter++;
- nCur++;
- if( *pIter > A[ nMax ] ) nMax = nCur;
- }
- pLast = &A[nMax];
- pIter = &A[0];
- while( pIter != pLast )
- {
- if( *pIter < 0 ) B.push_back( *pIter );
- pIter++;
- }
- for( auto& i : B )
- {
- cout << i << endl;
- }
- return 0;
- }#include <iostream>
- #include <vector>
- using namespace std;
- int main()
- {
- int A[] = { -5,1,-6,2,-7,3 };
- int n = sizeof( A ) / sizeof( int );
- std::vector< int > B;
- int* pIter = &A[ 0 ];
- int* pLast = &A[ n-1 ];
- int nMax = 0, nCur = 0;
- while( pIter != pLast )
- {
- pIter++;
- nCur++;
- if( *pIter > A[ nMax ] ) nMax = nCur;
- }
- pLast = &A[nMax];
- pIter = &A[0];
- while( pIter != pLast )
- {
- if( *pIter < 0 ) B.push_back( *pIter );
- pIter++;
- }
- for( auto& i : B )
- {
- cout << i << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement