📜  C++中画圆的程序——CSS代码示例

📅  最后修改于: 2022-03-11 14:47:47.255000             🧑  作者: Mango

代码示例2
#include using namespace std; int main() { float r; cout<< ” Enter the Radius”<> r; float pr = 2; // pr is the aspected pixel ratio which is almost equal to 2 for (int i = -r; i <= r; i++) // loop for horizontal movement { for (int j = -r; j <= r; j++) // loop for vertical movement { float d = ((i*pr)/r)*((i*pr)/r) + (j/r)*(j/r); //multiplying the i variable with pr to equalize pixel-width with the height if (d >0.95 && d<1.08) // approximation { cout << “*”; } else { cout << ” “; } } cout << endl; } return 0; }