Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- int n;
- scanf("%d",&n);
- double xie,xie_max=-1e12,x[1024],y[1024],px,py;
- for (int i = 0; i < n; i++)
- {
- scanf("%lf%lf",&x[i],&y[i]);
- }
- //input
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < n; j++)
- {
- if (x[i]>x[j])
- {
- px = x[i];
- py = y[i];
- x[i] = x[j];
- y[i] = y[j];
- x[j] = px;
- y[j] = py;
- }
- }
- }
- //place the smaller in the front
- for (int i = 0; i < n-1; i++)
- {
- xie = 1.0*(y[i]-y[i+1])/(x[i]-x[i+1]);
- if (xie > xie_max)
- {
- xie_max = xie;
- }
- }
- //judge the biggest one
- printf("%.3f",xie_max);
- }
Advertisement
Add Comment
Please, Sign In to add comment