diff options
Diffstat (limited to 'ACE/apps/JAWS3/bench/average.cpp')
-rw-r--r-- | ACE/apps/JAWS3/bench/average.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/ACE/apps/JAWS3/bench/average.cpp b/ACE/apps/JAWS3/bench/average.cpp new file mode 100644 index 00000000000..568f183dbb3 --- /dev/null +++ b/ACE/apps/JAWS3/bench/average.cpp @@ -0,0 +1,24 @@ +// $Id$ +#include "ace/OS.h" + +int +ACE_TMAIN(int, ACE_TCHAR *[]) +{ + double sum = 0; + double count = 0; + int input; + char buf[BUFSIZ]; + + while (ACE_OS::fgets (buf, sizeof (buf), stdin) != 0) + { + input = ACE_OS::atoi (buf); + sum += input; + count++; + } + + ACE_OS::printf ("sum of input is: %f\n", sum); + ACE_OS::printf ("number of inputs is: %f\n", count); + ACE_OS::printf ("average of input is: %f\n", sum / count); + + return 0; +} |