Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- #include <stdio.h>
- using namespace std;
- int
- ystart (int count, int mark)
- {
- int sisa;
- sisa = count % 3;
- switch (sisa)
- {
- case 0:
- return 2 * pow (3, mark);
- case 1:
- return 0;
- default:
- return pow (3, mark);
- }
- }
- int
- xstart (int count, int mark)
- {
- if (count < 4)
- {
- return 0;
- }
- else if (count > 3 && count < 7)
- {
- return pow (3, mark);
- }
- else
- {
- return 2 * pow (3, mark);
- }
- }
- int
- main ()
- {
- char array[729][729];
- for (int i = 0; i < 729; ++i)
- {
- for (int j = 0; j < 729; ++j)
- {
- array[i][j] = ' ';
- }
- }
- int input, count;
- array[0][0] = 'X';
- for (int mark = 0; mark < 6; ++mark)
- {
- count = 3;
- do
- {
- for (int x = xstart (count, mark), basea = 0; basea < pow (3, mark);
- ++x, ++basea)
- {
- for (int y = ystart (count, mark), baseb = 0;
- baseb < pow (3, mark); ++y, ++baseb)
- {
- array[x][y] = array[basea][baseb];
- }
- } count = count + 2;
- }
- while (count < 10);
- }
- cin >> input;
- do
- {
- input = pow (3, input - 1);
- for (int i = 0; i < input; ++i)
- {
- for (int j = 0; j < input; ++j)
- {
- cout << array[i][j];
- }
- cout << endl;
- }cout << "-"<<endl;
- cin >> input;
- }
- while (input > 0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement