home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 3 / RISC_DISC_3.iso / resources / etexts / gems / gemsv / ch2_7 / testlen4.c < prev   
C/C++ Source or Header  |  1995-04-04  |  590b  |  27 lines

  1. /*
  2.  * testlen4.c - len4 exerciser
  3.  *
  4.  * % cc -g testlen4.c len4.c -lm -o testlen4
  5.  * % ./testlen4 2 1 1 1 
  6.  * % ./testlen4 60000000 25000000 19000000 16000000
  7.  */
  8.  
  9. #include <stdio.h>
  10. #include <stdlib.h>    /* for atoi() */
  11. #include <math.h>
  12.  
  13. main(argc, argv)
  14.     char *argv[];
  15.     {
  16.     long a, b, c, d, l;
  17.     double l2;
  18.     a = atoi(argv[1]);
  19.     b = atoi(argv[2]);
  20.     c = atoi(argv[3]);
  21.     d = atoi(argv[4]);
  22.     l = len4(a,b,c,d);
  23.     l2 = hypot(hypot((double)(a),(double)(b)),
  24.            hypot((double)(c),(double)(d)));
  25.     printf("(%d,%d,%d,%d) = %d (%g)\n", a, b, c, d, l, l/l2);
  26.     }
  27.