On 10/30/07, Zoro.MONKEY <[EMAIL PROTECTED]> wrote:
>
>    I have seen my file again ,there's no space between "%"and "f".
> I still can not find where is the problem althought many people have told
> me many different reasons.Maybe I need more time to think about it...Thank u 
> so much!~

Try the following:

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

#define EPSILON 0.000001

/* Compares two floating point numbers for 'equality'
   Returns 0 if left ~= right
   Returns -1 if left < right
   Returns 1 if left > right
*/
int fp_compare(double left, double right){
   double diff = left-right;
   if (fabs(diff) > EPSILON){
      if (diff > 0){
         return 1;
      }else{
         return -1;
      }
   }
   return 0;
}

int main(void)
{
   float num_a, num_b, num_c;

   printf("Enter three integer(larger than zero):");
   scanf("%f%f%f", &num_a, &num_b, &num_c);

    printf("%f\n%f\n%f\n", num_a, num_b, num_c);

/*if(num_a + num_b <= num_c || num_a + num_c <= num_b || num_b + num_c
<= num_a)*/
if(fp_compare(num_a + num_b, num_c) <= 0 || fp_compare(num_a + num_c,
num_b) <= 0 || fp_compare(num_b + num_c, num_a) <= 0)
  printf("can't!\n");
else
  printf("can!\n");

            system("pause");
            return 0;
}



-- 
PJH
"Statistics are like a bikini. What they reveal is suggestive, but
what they conceal is vital"
-- Aaron Levenstein

Reply via email to