wojiaocbj

slope

Mar 14th, 2022
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.82 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.     int n;
  6.     scanf("%d",&n);
  7.     double xie,xie_max=-1e12,x[1024],y[1024],px,py;
  8.     for (int i = 0; i < n; i++)
  9.     {
  10.         scanf("%lf%lf",&x[i],&y[i]);
  11.     }
  12.     //input
  13.  
  14.     for (int i = 0; i < n; i++)
  15.     {
  16.         for (int j = 0; j < n; j++)
  17.         {
  18.             if (x[i]>x[j])
  19.             {
  20.                 px = x[i];
  21.                 py = y[i];
  22.                 x[i] = x[j];
  23.                 y[i] = y[j];
  24.                 x[j] = px;
  25.                 y[j] = py;
  26.             }
  27.         }
  28.     }
  29.     //place the smaller in the front
  30.  
  31.     for (int i = 0; i < n-1; i++)
  32.     {
  33.         xie = 1.0*(y[i]-y[i+1])/(x[i]-x[i+1]);
  34.         if (xie > xie_max)
  35.         {
  36.             xie_max = xie;
  37.         }
  38.     }
  39.     //judge the biggest one
  40.  
  41.     printf("%.3f",xie_max);
  42. }
Advertisement
Add Comment
Please, Sign In to add comment