#include <stdio.h>
float PI = 3.141592;
float pi1;
float pi2, sum = 0;
int count = 0;
int i;
int main(int argc, char** argv)
{
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;
}
}
printf("count = %d\n", count);
return 0;
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น