Write code to draw circle
Sigiloso
We can draw the circle by calculating values only for 1 quadrant. Following is code for reference. DIM is added to shift origin. #define DIM 22 #include #include #include using namespace std; int main() { vector > a(2*DIM, vector(2*DIM, ' ')); int r = DIM -1; for (int x = 0; x <= r; x++) { double yd = 0.5 + sqrt(r*r - x*x); int y = floor(yd); a[DIM + y][DIM + x] = '.'; a[DIM - y][DIM + x] = '.'; a[DIM + y][DIM - x] = '.'; a[DIM - y][DIM - x] = '.'; } for (int i = 0; i < a.size(); i++) { for (int j = 0; j < a[0].size(); j++) { cout << a[i][j]; } cout << endl; } return 0; }