I was translating a code from Python to C++ (of which i'm not a frequent user by far, understanding only a little more than just synthax) and got stuck at a point, where i need to format the b array and then remove the duplicates from already formatted array. At the very end, count the number of items in the array c. I have outline the problematic part (which i left written in Python). As you can see, i have a m_l array with 10 numbers, which will be used for 5 for loops. I have a preliminarily prepared b array where i will put all the possible sums comming out of the 5 for loop construction. Then, as it was mentioned earlier, i want to format items of b array, so each item has 4 numbers after dot (i.e. 128.7153). After formating i would move to duplications removal and then deremination of c array's items count. Would you please help me with that part? Thank you in advance. The code so far looks lite this:
#include <iostream>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
int main()
{
double m_l[10] = {12.05132, 178.0779, 52.13106, 44.15764, 100.15764, 726.0874, 109.11398, 9.11518,
198.10388, 36.0773}
vector<double> b;
for (int d = 0; d < 10; d++){
for(int e = 0; e < 10; e++){
for(int f = 0; f < 10; f++){
for(int g = 0; g < 10; d++){
for(int h = 0; h < 10; h++){
b.push_back(m_l[d]+m_l[e]+m_l[f]+m_l[g]+m_l[h]);}}}}}
int bSize = sizeof(b)/sizeof(b[0]);
cout << "The size of the b is: " << bSize << "\n";
cout << " " << "\n";
_______________________________________________________
myformattedlist = ["%.4f" % item for item in b]
c = set(myformattedlist)
_______________________________________________________
int cSize = sizeof(c)/sizeof(c[0]);
cout << "The size of the c is: " << cSize << "\n";
cout << " " << "\n";
return 0;
}