Advertisement
Guest User

Untitled

a guest
Sep 17th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.38 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. #include <stdio.h>
  4.  
  5. using namespace std;
  6. int
  7. ystart (int count, int mark)
  8. {
  9.   int sisa;
  10.   sisa = count % 3;
  11.   switch (sisa)
  12.     {
  13.     case 0:
  14.       return 2 * pow (3, mark);
  15.     case 1:
  16.       return 0;
  17.     default:
  18.       return pow (3, mark);
  19.     }
  20. }
  21.  
  22. int
  23. xstart (int count, int mark)
  24. {
  25.  
  26.   if (count < 4)
  27.     {
  28.       return 0;
  29.     }
  30.   else if (count > 3 && count < 7)
  31.     {
  32.       return pow (3, mark);
  33.     }
  34.   else
  35.     {
  36.       return 2 * pow (3, mark);
  37.     }
  38. }
  39.  
  40. int
  41. main ()
  42. {
  43.   char array[729][729];
  44.   for (int i = 0; i < 729; ++i)
  45.     {
  46.       for (int j = 0; j < 729; ++j)
  47.     {
  48.       array[i][j] = ' ';
  49.     }
  50.     }
  51.   int input, count;
  52.   array[0][0] = 'X';
  53.   for (int mark = 0; mark < 6; ++mark)
  54.     {
  55.       count = 3;
  56.       do
  57.     {
  58.       for (int x = xstart (count, mark), basea = 0; basea < pow (3, mark);
  59.            ++x, ++basea)
  60.         {
  61.  
  62.           for (int y = ystart (count, mark), baseb = 0;
  63.            baseb < pow (3, mark); ++y, ++baseb)
  64.         {
  65.           array[x][y] = array[basea][baseb];
  66.         }
  67.         } count = count + 2;
  68.     }
  69.       while (count < 10);
  70.  
  71.     }
  72.   cin >> input;
  73.   do
  74.     {
  75.       input = pow (3, input - 1);
  76.       for (int i = 0; i < input; ++i)
  77.     {
  78.       for (int j = 0; j < input; ++j)
  79.         {
  80.           cout << array[i][j];
  81.         }
  82.       cout << endl;
  83.     }cout << "-"<<endl;
  84.     cin >> input;
  85.     }
  86.   while (input > 0);
  87.  
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement