#include <iostream>
using std::cout;
using std::endl;
#include <iomanip>
using std::setw;
#include <ctime>
void main()
{
const int first = 5, second = 5;
int firstArray[first][second] = {0};
int secondArray[first][second] = {0};
int thirdArray[first][second]= {0};
int fourthArray[]= {0};
int i, j, temp = 0;
srand(time(0));
for (i = 0; i < first - 1; i++)
{
for (j = 0; j < second - 1; j++)
cout << setw(6) << firstArray[j] << '\t';
cout << endl;
}
cout << endl << "This is the firstArray: " << endl;
for (i = 0; i < first - 1; i++)
{
for (j = 0; j < second - 1; j++)
{
firstArray[j] = 1 + rand() % (first * second);
cout << firstArray[j] << '\t';
}
cout << endl;
}
for (i = 0; i < first - 1; i++)
{
for (j = 0; j < second - 1; j++)
cout << setw(6) << secondArray[j] << '\t';
cout << endl;
}
cout << endl << "This is the secondArray: " << endl;
for (i = 0; i < first - 1; i++)
{
for (j = 0; j < second - 1; j++)
{
secondArray[j] = 1 + rand() % (first * second);
cout << secondArray[j] << '\t';
}
cout << endl;
}
cout << endl;
cout << "This is the thirdArray: " << endl;
for (i = 0; i < first - 1; i++)
{
for (j=0; j < second - 1; j++)
{
if (firstArray[j] > secondArray[j])
thirdArray[j] = firstArray[j];
else
thirdArray[j] = secondArray[j];
cout << thirdArray[j] << '\t';
}
cout << endl;
}
cout << endl;
cout << "This is the fourthArray: " << endl;
for (i = 0; i < first - 1; i++)
{
for (j = 0; j < second - 1 ; j++)
{
fourthArray[j] = thirdArray[j];
cout << fourthArray[j] << '\t';
}
cout << endl;
}
cout << endl;
for (i = 0; i < first - 1; i++)
{
for (j = 0; j < second - 1; j++)
{
if (fourthArray[j] > fourthArray[j + 1])
{
temp = fourthArray[j];
fourthArray[j] = fourthArray[j + 1];
fourthArray[j + 1] = temp;
}
}
cout << endl;
}
return;
}
using std::cout;
using std::endl;
#include <iomanip>
using std::setw;
#include <ctime>
void main()
{
const int first = 5, second = 5;
int firstArray[first][second] = {0};
int secondArray[first][second] = {0};
int thirdArray[first][second]= {0};
int fourthArray[]= {0};
int i, j, temp = 0;
srand(time(0));
for (i = 0; i < first - 1; i++)
{
for (j = 0; j < second - 1; j++)
cout << setw(6) << firstArray[j] << '\t';
cout << endl;
}
cout << endl << "This is the firstArray: " << endl;
for (i = 0; i < first - 1; i++)
{
for (j = 0; j < second - 1; j++)
{
firstArray[j] = 1 + rand() % (first * second);
cout << firstArray[j] << '\t';
}
cout << endl;
}
for (i = 0; i < first - 1; i++)
{
for (j = 0; j < second - 1; j++)
cout << setw(6) << secondArray[j] << '\t';
cout << endl;
}
cout << endl << "This is the secondArray: " << endl;
for (i = 0; i < first - 1; i++)
{
for (j = 0; j < second - 1; j++)
{
secondArray[j] = 1 + rand() % (first * second);
cout << secondArray[j] << '\t';
}
cout << endl;
}
cout << endl;
cout << "This is the thirdArray: " << endl;
for (i = 0; i < first - 1; i++)
{
for (j=0; j < second - 1; j++)
{
if (firstArray[j] > secondArray[j])
thirdArray[j] = firstArray[j];
else
thirdArray[j] = secondArray[j];
cout << thirdArray[j] << '\t';
}
cout << endl;
}
cout << endl;
cout << "This is the fourthArray: " << endl;
for (i = 0; i < first - 1; i++)
{
for (j = 0; j < second - 1 ; j++)
{
fourthArray[j] = thirdArray[j];
cout << fourthArray[j] << '\t';
}
cout << endl;
}
cout << endl;
for (i = 0; i < first - 1; i++)
{
for (j = 0; j < second - 1; j++)
{
if (fourthArray[j] > fourthArray[j + 1])
{
temp = fourthArray[j];
fourthArray[j] = fourthArray[j + 1];
fourthArray[j + 1] = temp;
}
}
cout << endl;
}
return;
}