Advertisement
STANAANDREY

CAIUS conc

May 7th, 2019
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.32 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. ifstream fin("file.in");
  4. ofstream fout("f.out");
  5.  
  6. void generate_3angle(short n,short line,short col,bool full),generate_forest(),generate_tree(short n,short line,short col,bool full);
  7.     bool forest[505][505];
  8.  
  9. int main() {
  10. srand(time(NULL));
  11. generate_forest();
  12. for (short i=0;i<505;i++) {
  13. for (short j=0;j<505;j++)
  14. if(forest[i][j])
  15.     fout<<'*';
  16. else
  17.     fout<<' ';
  18.  fout<<"\n";
  19. }
  20.   return EXIT_SUCCESS;
  21. }
  22.  
  23.  
  24. void generate_3angle(short h,short line,short col,bool full)
  25. {
  26.     short copy_col,i,cn=h;
  27.  for (short c=0;c<h;c++)
  28. {
  29.     forest[line][col]=1;
  30.    copy_col=col-1;
  31.    for (i=0;i<cn-1&&line&&col;i++,copy_col--)
  32.     if (rand()%2||full)
  33.    forest[line][copy_col]=1;
  34.    copy_col=col+1;
  35.    for (i=0;i<cn-1&&line&&col;i++,copy_col++)
  36.     if (rand()%2||full)
  37.    forest[line][copy_col]=1;
  38.    line--;cn--;
  39. }
  40.  
  41.  
  42. }
  43.  
  44. void generate_tree(short n,short tline,short tcol,bool full)
  45. {
  46. forest[tline][tcol]=1;
  47. forest[tline-1][tcol]=1;
  48. generate_3angle(n+1,tline-2,tcol,full);
  49. generate_3angle(n,tline-n-3,tcol,full);
  50. }//*//
  51.  
  52. void generate_forest()
  53. {
  54.  int m=rand()%500+500;
  55. for (short i=25;i<480;i+=11)
  56.  for (short j=25;j<480;j+=24)
  57.  {
  58.      if (rand()%2) {
  59.      generate_tree(rand()%10,i,j,rand()%2);
  60.      m--;
  61.      }
  62.      if (!m)
  63.         return;
  64.  }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement