numpy generate random 2d array
import numpy as np
a=np.random.rand(3,3)
print(a)
numpy generate random 2d array
import numpy as np
a=np.random.rand(3,3)
print(a)
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
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us