Percolation/Bond percolation: Difference between revisions

C++: translation information updated.
(C++: use signed int)
(C++: translation information updated.)
Line 162:
 
=={{header|C++}}==
{{trans|CD}}
<lang cpp>#include <cstdlib>
#include <cstring>
Line 204:
void show() const {
for (auto j = 0; j < m; j++)
cout << ("+--");
cout << '+' << endl;
 
Line 210:
cout << (i == n ? ' ' : '|');
for (auto j = 0; j < m; j++) {
cout << ((cells[i * m + j] & FILL) ? "[]#" : " ");
cout << ((cells[i * m + j] & RWALL) ? '|' : ' ');
}
Line 218:
 
for (auto j = 0; j < m; j++)
cout << ((cells[i * m + j] & BWALL) ? "+--" : "+ ");
cout << '+' << endl;
}
Line 251:
int main() {
const auto M = 10, N = 10;
const Grid grid(.5, M, N);
grid.percolate();
grid.show();
Anonymous user