Advertisement
cd62131

Max

Jul 29th, 2014
433
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.41 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3. int main(void) {
  4.   const char * fname = "test.dat";
  5.   char line[BUFSIZ];
  6.   double amp, time, max, max_abs = 0;
  7.   FILE *in = fopen(fname, "r");
  8.   while (fgets(line, BUFSIZ, in)) {
  9.     sscanf(line, "%lf%lf", &time, &amp);
  10.     if (fabs(amp) > max_abs) {
  11.       max = amp;
  12.       max_abs = fabs(max);
  13.     }
  14.   }
  15.   fclose(in);
  16.   printf("max: %.7lf\n", max);
  17.   return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement