Compilation Error: math functions?

Write here if you have problems with your C source code

Moderator: Board moderators

Post Reply
Aengus
New poster
Posts: 12
Joined: Thu Oct 30, 2003 1:38 pm
Location: St. Petersburg, Russia
Contact:

Compilation Error: math functions?

Post by Aengus » Tue Jun 06, 2006 6:32 pm

I submitted the following code and got the compilation error (jeez... the second one in two days):

Code: Select all

#include <math.h>
#include <stdio.h>

int
main()
{
  int i, n;
  scanf("%d", &n);

  for (i = 0; i < n; i++)
  {
    double b, h, r0, tau, m, res;
    scanf("%lf %lf", &b, &h);

    b  /= 2;
    r0  = 2*b*h / (b + sqrt(b*b + h*h));

    if (r0 >= 0.000001)
    {
      tau = 1 - r0/h;
      m   = floor((log(0.000001) - log(r0)) / log(tau));
      res = h - r0 * exp(m * log(tau)) / (1 - tau);
    }
    else
      res = 0;

    if (i > 0) printf("\n");
    printf("%13.6f\n", res*M_PI);
  }

  return 0;
}
The only functions besides printf and scanf here are mathematical ones from math.h: sqrt(), floor(), log(), exp(). I also use M_PI constant. Could anything of this cause the fault of compilation?

mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:

Post by mf » Tue Jun 06, 2006 6:47 pm

M_PI constant is not defined in judge's version of math.h.

Aengus
New poster
Posts: 12
Joined: Thu Oct 30, 2003 1:38 pm
Location: St. Petersburg, Russia
Contact:

Post by Aengus » Tue Jun 06, 2006 6:59 pm

Thanks a lot. It helped.

Post Reply

Return to “C”