/*打印圆形*/
#include <iostream>
#include <math.h>
using namespace std;
void print_circle(int);
double D(int, int);
int main()
{
int R;/*变量半径*/
cout << "请输入半径:" << endl;
cin >> R;
print_circle(R);
}
void print_circle(int R)
{
double a = 0, b = 0;/*a是列数,b是行数*/
for (b = 0; b <= (2 * R); b++)
{
for (a = 0; a <= (2 * R); a += 0.5)
{
if (a >= (R - D(b, R)) && a <= (R + D(b, R)))
cout << "*";
else cout << " ";
}
cout << '\n';
}
}
double D(int b, int R)
{
double a;
a = sqrt((2 * R - b) * b);
return a;
}