#include <bits/stdc++.h>
using namespace std;
int main(){
const int rows = 100, cols = 100;
double p = 0.3;
srand(time(0));
for (int i = 0; i < rows; i++){
for (int j = 0; j < cols; j++){
double r = static_cast<double>(rand()) / RAND_MAX;
if(r < p)
cout << "1";
else
cout << "0";
}
cout << "\n";
}
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #include <bits/stdc++.h> using namespace std; int main(){ const int rows = 100, cols = 100; double p = 0.3; srand(time(0)); for (int i = 0; i < rows; i++){ for (int j = 0; j < cols; j++){ double r = static_cast<double>(rand()) / RAND_MAX; if(r < p) cout << "1"; else cout << "0"; } cout << "\n"; } return 0; } |
English