float PI = 3.141592;
float pi1;
float pi2, sum = 0;
int count = 0;
int i;
for (i = 1; i < 5000000; i += 4)
{
if (PI - sum != 0)
{
pi1 = (float)4 / i;
sum = sum + pi1;
count++;
}
else
{
break;
}
if (PI - sum != 0)
{
pi2 = (float)4 / (i + 2);
sum = sum - pi2;
count++;
}
else
{
break;
}
}
cout << count << endl;
ไม่มีความคิดเห็น:
แสดงความคิดเห็น