Arrays: Arguments + Two Dimensions: please only respond if you can get close to
ID: 652846 • Letter: A
Question
Arrays: Arguments + Two Dimensions: please only respond if you can get close to sample output. C++
Section 1: Create a function that receives an array as an argument, and displays the two dimensional array. (Displaying function) Section 2: Create a function that receives two arrays as arguments, and transforms the first array and store the result into the second array.(Transforming function) Section 3: Main function. Set a random number seed to 1 followed by the last 3 digits of your student ID. Declare two arrays, both 5 X 5 array.Populate the first array with random numbers that are 2 digits long (10 through 99).Section 4: invoke the Display function by passing the first array as argument. Section 5: Invoke the Transforming function by passing two arrays as arguments. Section 6: Invoke the Display function by passing the resulting array as argument.
must match output: heres link
https://onedrive.live.com/redir?resid=3274BC86E4F10732!1692&authkey=!APHgrVI2MiPVzPw&v=3&ithint=photo%2cjpg
Explanation / Answer
#include<iostream>
#include<iomanip>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
const int numRows = 5;
const int numCols = 5;
int roll();
void sortArx();
void dispArray(int[numRows][numCols]);
void sortArray(int[numRows][numCols]);
void main()
{
srand(1543);
int val[numRows][numCols] = { roll(), roll(), roll(), roll(), roll(),
roll(), roll(), roll(), roll(), roll(),
roll(), roll(), roll(), roll(), roll(),
roll(), roll(), roll(), roll(), roll(),
roll(), roll(), roll(), roll(), roll(), };
dispArray(val);
sortArray(val);
cout << endl;
dispArray(val);
}
void dispArray(int nums[numRows][numCols])
{
int i, j;
for (i = 0; i < numRows; i++)
{
for (j = 0; j < numCols; j++)
{
cout << setw(3) << nums[i][j] << " ";
}
cout << endl;
}
}
void sortArray(int nums[numRows][numCols])
{
for (int irow = 0; irow<5; irow++)
{
for (int icol = 0; icol<5; icol++)
{
for (int jrow = 0; jrow<5; jrow++)
{
for (int jcol = 0; jcol<5; jcol++)
{
if (nums[irow][jrow]>nums[icol][jcol])
{
int temp = nums[irow][jrow];
nums[irow][jrow] = nums[icol][jcol];
nums[icol][jcol] = temp;
}
}
}
}
}
}
int roll()
{
int random;
random = 10 + rand() % 90;
return random;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.