Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- ifstream fin("file.in");
- ofstream fout("f.out");
- void generate_3angle(short n,short line,short col,bool full),generate_forest(),generate_tree(short n,short line,short col,bool full);
- bool forest[505][505];
- int main() {
- srand(time(NULL));
- generate_forest();
- for (short i=0;i<505;i++) {
- for (short j=0;j<505;j++)
- if(forest[i][j])
- fout<<'*';
- else
- fout<<' ';
- fout<<"\n";
- }
- return EXIT_SUCCESS;
- }
- void generate_3angle(short h,short line,short col,bool full)
- {
- short copy_col,i,cn=h;
- for (short c=0;c<h;c++)
- {
- forest[line][col]=1;
- copy_col=col-1;
- for (i=0;i<cn-1&&line&&col;i++,copy_col--)
- if (rand()%2||full)
- forest[line][copy_col]=1;
- copy_col=col+1;
- for (i=0;i<cn-1&&line&&col;i++,copy_col++)
- if (rand()%2||full)
- forest[line][copy_col]=1;
- line--;cn--;
- }
- }
- void generate_tree(short n,short tline,short tcol,bool full)
- {
- forest[tline][tcol]=1;
- forest[tline-1][tcol]=1;
- generate_3angle(n+1,tline-2,tcol,full);
- generate_3angle(n,tline-n-3,tcol,full);
- }//*//
- void generate_forest()
- {
- int m=rand()%500+500;
- for (short i=25;i<480;i+=11)
- for (short j=25;j<480;j+=24)
- {
- if (rand()%2) {
- generate_tree(rand()%10,i,j,rand()%2);
- m--;
- }
- if (!m)
- return;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement