Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- void rysuj(char c, int x, int y,
- int tx, int ty, char** tab)
- {
- tab[y+ty][x+tx] = c;
- }
- int main()
- {
- int r;
- char** board;
- cout << "Podaj promien ";
- cin >> r;
- board = new char*[2*r+1];
- for (int i = 0; i < r*2+1; i++)
- {
- board[i] = new char[2*r+1];
- for (int j = 0; j < r*2+1; j++)
- board[i][j] = ' ';
- }
- int tx = r;
- int ty = r;
- double widthFactor = 0.5;
- for(int i = -r; i <= r; i++)
- {
- rysuj('#',i,widthFactor*round(sqrt(r*r-i*i)),
- tx,ty,board);
- rysuj('#',i,-widthFactor*round(sqrt(r*r-i*i)),
- tx,ty,board);
- }
- for (int i = 0; i < r*2+1;i++)
- {
- for (int j = 0; j < 2*r+1;j++)
- {
- cout << board[i][j];
- }
- cout << "\n";
- }
- for (int i = 0; i < r*2+1; i++)
- delete[] board[i];
- delete[] board;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement