hey guys i have 3 arrays (even, odd and negative), they are all different sizes, but they maximum elements they can have is 50. how do i write them to a file in this format
EVEN ODD NEGATIVE
2 3 -2
4 5 -4
6 7 -9
i have no idea.. please help... i know the code above is wrong, but thats the best i got
EVEN ODD NEGATIVE
2 3 -2
4 5 -4
6 7 -9
Code:
size = 50; //they dont all 50, its just that array cant be bigger than 50
for (int i =0; i < size; i++)
{
cout <<setw(5);
if (even[i] != 0)
{
myfile << eList[i];
myfile << endl;
}
else
myfile << " ";
}
for (int i =0; i < size; i++)
{
cout <<setw(5);
if (odds[i] != 0)
{
myfile << oList[i];
myfile << endl;
}
else
myfile << " ";
}
for (int i =0; i < size; i++)
{
myfile <<setw(5);
if (negatives[i] != 0)
{
myfile << nList[i];
myfile << endl;
}
else
myfile << " ";
}