C++ VECTORS Need Help

Create a vector that contains set of positive and negative numbers of size ‘N’. The maximum length of each element in a set is based on vector size “N”. For example if the vector size is ‘6’ then the maximum length of each element is “6”. Example of vector elements is {-343, 2324, 345543,-56554, 564, 36733}. The vector elements must be read as integer not as characters. Must Use operator overloading function such as Insertion (<<) and extraction (>>) operators respectively to read vector elements and display the final output. Include necessary constructors and membership functions.

Use increment operator (++obj not obj++) to perform the following operations; The sum between each element in array will be calculated based on the length of each element that matches with other elelments:
For the above example in vector the length of each elements is:

  1. -343 length is ‘3’, 2324 length is ‘4’, 345543 length is ‘6’, -56554 length is ‘5’, 564 length is ‘3’ and 36733 length is ‘5’. Hence the sum is calculated as follows:
  2. -343+564=221
  3. -56554+36733=-19821
  4. 2324= 4232 (since the length is ‘4’ and it is not matched with any other elements in an array, it should be stored in reversed order).
  5. 345543=345543
  6. 345543=345 (since the length is ‘6’ and it is not matched with any other elements in an array, it should be stored in reversed order & it is also a palindrome, hence remove the repeated digits in the secondary part of the palindrome(Marked in BOLD) recursively until no palindrome is presents)
  7. In the first round the array is {221, -19821,4232,345}
  8. Use steps 1-6 recursively, until the length of the digit is not same in an array.
    Ie. 221 length is ‘3’, -19821 length is ‘5’, 4232 length is ‘4’ and 345 length is ‘3’, since the first and last elements are having same length then sum both:
    221+345=566; length is 3
    -19821 =-12891 (reversed); length is 5
    4232 =2324 (reversed); length is 4
  9. The vector elements are now {566, -12891, 2324}, //refer no elements are in the same length.
    Use unary operator (obj=-obj) overloading function to convert the above elements as positive numbers to negative numbers and vice-versa. i.e After the conversion the vector elements are {-566, 12891,-2324) & Finally arrange the vector elements according to the increasing order of elements length irrespective of sign (+, or -).
    Ie. The final output would be for the above example:{-566, -2324, 12891}.
    *Note: Your are free to use STL such as vectors & predefined reverse and sorting functions.
    Example:
    Input:
    6 //size of the Vector
    -343
    2324
    345543
    56554
    564
    36733
    The Output:
    {-566,-2324,12891}
2 Likes

Where is ans for this…

1 Like

Please send the code for this!