Skip to content

Instantly share code, notes, and snippets.

@frzleaf
Created November 11, 2015 11:32
Show Gist options
  • Save frzleaf/40ff6b69269613bafbbb to your computer and use it in GitHub Desktop.
Save frzleaf/40ff6b69269613bafbbb to your computer and use it in GitHub Desktop.
/*
* Bai 4.6
* Le Quang Thanh - 11020287
*/
#include <iostream>
#include <cstdlib>
using namespace std;
int main(){
int m, n;
bool **a;
cout << "Nhap m & n: ";
cin >> m >> n;
a = new bool*[m];
double hrandm = RAND_MAX/2;
cout << " ";
for ( int i = 0 ; i < n ; ++i )
cout << i << " ";
cout << endl;
for ( int i = 0 ;i < m ; ++i ){
a[i] = new bool[n];
cout << i ;
for ( int j = 0; j < n; ++j ){
a[i][j] = (rand() < hrandm );
if ( a[i][j] )
cout << "* ";
else
cout <<" ";
}
cout << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment