So I am struggling with writing one piece of code that will remove the duplicates from an parallel array. the file will be read then processed using two arrays but that's easy the part which i cannot figure out is for example when i have numbers like this:
750 10
150 35
750 19
450 18
610 19
390 19
520 6
410 78
300 23
410 1
410 5
120 6
lets say that the first one refers to I don't know, flowers sold and the second one refers to the group that sold them. How would I write the code so that it would compare the arrays and if the group is the same added them to the previous group if found if not create one. I know I should probably use for loop but I spent tons of time and cant seem to figure it out. any help would be much appreciated. P.S. sorry for bad English its my secondary language I am learning it right now as well :) This is what i Have as of now but i cannot figure out what to put in the loops and what to send to a function. Im trying to solve this my loops and functions only no map etc.
#include <iostream>
#include <fstream>
using namespace std;
ifstream inputFile; //stream object
void Duplicate(int);
int main()
{
const int SIZE = 12;
inputFile.open("boxes.txt");
int candy[SIZE];
int dept[SIZE];
while (inputFile >> candy[SIZE] >> dept[SIZE] )
{
for (int i = 0; i < SIZE; i++)
{
if (dept[i])
cout << "old: " << dept[i] << endl;
Duplicate(s[i]);
if (s[i])
cout << "new: " << s[i] << endl;
}
}
return 0;
}
void Duplicate(int s[])
{
}