Dec 26, 2013 at 12:57pm UTC
hey guys..
so i'm trying to build a 2d array of randomized numbers and display them properly ,now all the numbers inside the array are generated properly but for the display on screen part it gives me the randome numbers but not in an unified column or in other words not all the numbers are beneath each other directly.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
using namespace std;
void display(int disray[][20],int z,int x)
{
disray[z][x];
for (int ro=0;ro<z;ro++)
{
for (int co=0;co<x;co++)
{
cout << "|| " ;
cout << disray[ro][co];
cout<< " " ;
}cout<< "||" << endl;
}
}
void strrand(int arr[][20], int k,int l)
{
arr[k][l];
srand(time(0));
for (int ro=0;ro<k;ro++){
for (int co=0;co<l;co++){
arr[ro][co]=(rand()%31+rand()%7-rand()%25);
}
}
}
int main ()
{
int row,column;
cout << " ENTER NO. of Rows==" <<endl;
cin >> row;
cout << " ENTER NO. of Columns==" <<endl;
int array[row][20];
cin >> column;
cout <<" LET's Start ==" << endl;
strrand(array,row,column);
display(array,row,column);
return 0;
}
so please help ,thanks;:)
Ps:if you can show me how to replace any number of the array with a letter that would be awesome.
Last edited on Dec 26, 2013 at 1:22pm UTC