123456789101112131415161718192021222324252627282930313233343536
#include <iostream> #include<ctime> #include<cstdlib> using namespace std; int main() { srand(time(NULL)); char obj[3]={'|','_',' '}; int n; cout<<"Enter the size of the maze (nxn): "; cin>>n; char maze[n][n]; system("cls"); for(int i=0;i<n;i++) { for(int j=0;j<n;j++) { int r=rand()%3; maze[i][j]=obj[r]; } } for(int i=0;i<n;i++) { for(int j=0;j<n;j++) cout<<maze[i][j]; cout<<endl; } }