![]() |
prog/02 のバックアップ(No.4) |
#include<stdio.h> int main(){ int N=20000,i=N-1,j,c=0; for(j=1;j<N;j++){ while(i*i+j*j>N*N)i--;c+=i; } printf("pi=%d\n",c+N-1); return 0; }
#include <stdio.h> #define N 10000 int main() { int i = N - 1, j, c = 0; for (j = 1; j < N; j++) { while (i * i + j * j > N * N) i--; c += i; } printf("pi=%d\n", c * 4 + 4 * N - 2); return 0; }
#include <stdio.h> main() { int N = 20000, i = N - 1, j, c = 0; for (j = 1; j < N; j++) { while (i * i + j * j > N * N) i--; c += i; } printf("%d\n", c + N); }
#include <stdio.h> main() { int N = 20000, i = N, j, c = N; for (j = 1; j < N; j++) { while (i * i + j * j > N * N) i--; c += i; } printf("%d\n", c); }
#include <stdio.h> main() { int i; double p = 0; for (i = 1; i < 4000000; i += 4) p += 4. / i - 4. / (i + 2); printf("%.8f\n", p); }
int N=20000,i=N,j,c=N;for(j=1;j<N;j++){while(i*i+j*j>N*N)i--;c+=i;}printf("%d\n",c); int i;double p=0;for(i=1;i<4000000;i+=4)p+=4./i-4./(i+2);printf("%.8f\n",p);
#include "osecpu_ask.h" #define N 20000 Int32s n:R00, i:R01, c:R02, nn:R03, j:R04; n = N; i = n; c = i; nn = c * c; for (j = 1; j != n; j++) { for (;;) { if (j * j + i * i <= nn) break; i--; } c += i; } api_putStringDec('\1', c, 9, 0);
#include "osecpu_ask.h" #define N 0x8000000 Int32s c:R00, i:R01, p:R02; c = 400000000; for (i = 1; i < N; i += 2) { p += c / i; c *= -1; } api_putStringDec('\1', p, 9, 0);
コメント | お名前 | NameLink | |