Advertisement
Guest User

Untitled

a guest
Jul 10th, 2016
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.69 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. #include "guess_max_fn.c"
  4.  
  5. int main(int argc, char * argv[]) {
  6.     int N, count, real_idx;
  7.     double real_max = -1;
  8.     double your_max = -1;
  9.     int your_idx = -1;
  10.     int done = 0;
  11.  
  12.     scanf("%d", &N);
  13.  
  14.     for(count=1; count<=N; count++) {
  15.         double x;
  16.         scanf("%lf", &x);
  17.         if (!done && (done=guess_max(x, N, count))) {
  18.             your_max = x;
  19.             your_idx = count;
  20.         }
  21.         if (real_max < x) {
  22.             real_max = x;
  23.             real_idx = count;
  24.         }
  25.     }
  26.  
  27.     if(your_max < real_max) {
  28.         printf("Pudło! (N=%d); Real max:%.15f (idx=%d); Your choice:%.15f (idx=%d)\n", N, real_max, real_idx, your_max, your_idx);
  29.     }else{
  30.         printf("Trafiony! (N=%d) idx=%d max=%.15f\n", N, real_idx, real_max );
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement