fork download
  1. #include <math.h>
  2. #include <stdio.h>
  3.  
  4. int main(void)
  5. {
  6. int N=1<<15;
  7. int i;
  8. int n=0;
  9. double d=6.25/(double)N;
  10. for (i=0; i<=N; i++)
  11. {
  12. double t=i*d;
  13. double c=cos(t);
  14. double s=sin(t);
  15. double v=c*c+s*s;
  16. if (v==1.0) n++;
  17. }
  18. printf("%d\t%d\n",n,n*100/N);
  19. return 0;
  20. }
  21.  
Success #stdin #stdout 0s 9424KB
stdin
Standard input is empty
stdout
25455	77