mirror of
git://projects.qi-hardware.com/ben-wpan.git
synced 2024-11-17 01:36:13 +02:00
34 lines
406 B
C
34 lines
406 B
C
|
#include <stdio.h>
|
||
|
#include <math.h>
|
||
|
|
||
|
|
||
|
#define N 100
|
||
|
|
||
|
|
||
|
int main(int argc, char **argv)
|
||
|
{
|
||
|
float c[2];
|
||
|
int n = 0;
|
||
|
float sum = 0;
|
||
|
size_t s;
|
||
|
|
||
|
|
||
|
while (1) {
|
||
|
s = fread(c, sizeof(c), 1, stdin);
|
||
|
if (!s) {
|
||
|
if (!ferror(stdin))
|
||
|
break;
|
||
|
if (s < 0) {
|
||
|
perror("read");
|
||
|
return 1;
|
||
|
}
|
||
|
}
|
||
|
sum += hypot(c[0], c[1]);
|
||
|
if (n++ % N)
|
||
|
continue;
|
||
|
printf("%f\n", sum/N);
|
||
|
sum = 0;
|
||
|
}
|
||
|
return 0;
|
||
|
}
|