【开源】随机生成一副黑白相间的地图

发布时间 2023-11-30 17:24:08作者: daiyulong

code

#include<bits/stdc++.h>
using namespace std;
string mp[105][105];
int main() {
	srand(time(0));
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++) {
		for(int j=1;j<=m;j++) {
			if(rand()%2==1) {
				mp[i][j]="□";
			} else {
				mp[i][j]="▇ ";
			}
		}
	}
	for(int i=1;i<=n;i++) {
		for(int j=1;j<=m;j++) {
			cout<<mp[i][j];
		}
		cout<<endl;
	}
	return 0;
}