these numbers are made up and i have to have 17 numbers in each row. a function has to print out these numbers. they have to be entered manually.
i also have to print the three arrays separately in another function, it should look like this:
1 2 3 4 5
here is the score1 array:
4 4 4 4 4
4 4 4 4 4 //they have to aligned like this. 5 a row.
4 4 4 4 4
4 4
//this function reads the arrays
void readthearrays (int score1[], int score2[], int score3[], int k) {
int j;
//i have to make the 3 arrays with 17 numbers print from this array.
for (j = 0; j < k; j++) {
cin>> score1[17] >> setw(10) >> score2[17]>> setw(10)>> score3[17];
}
return;
}
//this function prints the arrays.
void printarray (int nums[], int k) {
int j; //i have to print the scores separately using this function and they have to be 5 numbers in a row.
for (j = 0; j < k; j++) {
cout<< j << setw(5) << j << endl;
}
return;
}
oh. i have tried to fix this myself and i have a new code. now the problem is that the in the "here is the score1 array" part the 17 numbers arent printed its only the first number in each array that is printed 17 times.
this is my function:
1 2 3 4 5 6 7 8 9 10 11 12
void printarray (int nums[], int k) {
int j;
for (j = 0; j < k; j++)
{
cout << setw(5) << nums[k];
if (j % 5 == 4)
cout << endl;
}
}
If you know all the array names and values will be less than 8 chars long, you can just put in << "\t" to tab to the desired distance apart.
If the values will be larger than 8 chars make a if loop to check the size.
example if less than 8, cout << "\t\t\t" else cout << "\t\t"
If you want 5, or 10 spaces between each char you could create a string of spaces and output those.