Search
 
SCRIPT & CODE EXAMPLE
 

CPP

two dimensional array A[N,M] with the random numbers from 10 to 90.

#include <iostream>
#include <ctime> // For time()
#include <cstdlib>  // For srand() and rand() 
#include <iomanip>
using namespace std;
 int table[5][10];
void sortarray (int[], int);
void showarray (int[], int);

int main()
{
	const int row=5;
	const int column=10;
	int table[row][column];
	int rnum;
	int t[row];
	
	srand(time(0));  // Initialize random number generator. 
	rnum = (rand() % 100) + 1;	
	


	for(int r=0; r<row; r++)//row	
	{ for(int c=0; c<column; c++)
	table [r][c] = (rand()%100) + 1;
	}
	
	for(int r=0; r<row; r++)//row	
	{ for(int c=0; c<column; c++) //column
	 
	{ 
		cout << setw(5) << table[r][c] << ' '; //display table
		 
	}
		cout << endl;
	}   


sortarray (t, row);

	cout << "your new sorted table is:  ";
	 showarray ( t, row);


	
	
	system("pause");		
	return 0;

}



void sortarrray(int t[], int elems)
{
	int temp;
	bool swap;

	do
	{
		swap=false;
		for (int count=0; count < (elems-1); count++)
		{
			if (t[count] > t[count +1])
			{ 
				 temp = t[count];
				t[count]=t[count +1];
				t[count +1]= temp;
				swap=true;
			}
		}
	}while (swap);
}





void showarray (int t[], int elems)
{
	for (ount] << " ";
	cout << endl;int count=0; count < elems; count++)
		cout << t[c
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: CPP print executable name 
Cpp :: code runner c++ syntax error 
Cpp :: solve problem of getline 
Cpp :: how to increase the length of a string 
Cpp :: use textchanged qt cpp 
Cpp :: time_t c++ stack overflow 
Cpp :: c++ error missing terminating character 
Cpp :: sort array in descending order c++ 
Cpp :: Variabili globali c++ 
Cpp :: C++14 (gcc 8.3) sample 
Cpp :: c++ bind port 
Cpp :: switch cout print with a prameter c++ 
Cpp :: dream speedrun song mp4 
Cpp :: pointers mcq sanfoundry 
Cpp :: default parameter c++ a field 
Cpp :: tu hi hai aashiqui song lyrics 
Cpp :: sqrt function in c++ 
Cpp :: unions c++ 
Cpp :: how to i convert C++ into C 
Cpp :: cpprestsdk header 
Cpp :: c++ trim string 
Cpp :: fibonacci sequence c++ 
Cpp :: sort c++ stl 
Cpp :: txt auslesen c++ 
Cpp :: cpp cout more than 1 value 
Cpp :: operazioni aritmetiche c++ 
Cpp :: 1047. Remove All Adjacent Duplicates In String solution leetcode in c++ 
Cpp :: convert char to C 
Cpp :: printing sub arrays 
Cpp :: c++ language 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =