标签:isp case 没有 tput positive nts 智商 can ted
Input
The first line of input is 8 positive numbers which indicate the coordinates of four points that must be on each diagonal.The 8 numbers are x1,y1,x2,y2,x3,y3,x4,y4.That means the two points on the first rectangle are(x1,y1),(x2,y2);the other two points on the second rectangle are (x3,y3),(x4,y4).
Output
For each case output the area of their intersected part in a single line.accurate up to 2 decimal places.
Sample Input
1.00 1.00 3.00 3.00 2.00 2.00 4.00 4.00 5.00 5.00 13.00 13.00 4.00 4.00 12.50 12.50
Sample Output
1.00 56.25
// 没考虑无相交区域
1 #include<stdio.h> 2 int main() 3 { 4 double x1,y1, x2,y2, x3,y3, x4,y4, a,b, t; 5 while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4)!=EOF) 6 { 7 if(x1>x2) 8 { t=x2; x2=x1; x1=t; } 9 if(y1>y2) 10 { t=y2; y2=y1; y1=t; } 11 if(x3>x4) 12 { t=x4; x4=x3; x3=t; } 13 if(y3>y4) 14 { t=y4; y4=y3; y3=t; } 15 a=x1-x4>x3-x2?x1-x4:x3-x2; 16 b=y1-y4>y3-y2?y1-y4:y3-y2; 17 printf("%.2f\n", a*b); 18 } 19 return 0; 20 }
// 还是错得离谱 感觉没有智商T^T
1 #include<stdio.h> 2 int main() 3 { 4 double x1,y1, x2,y2, x3,y3, x4,y4, a,b, t; 5 while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4)!=EOF) 6 { 7 if(x1>x2) 8 { t=x2; x2=x1; x1=t; } 9 if(y1>y2) 10 { t=y2; y2=y1; y1=t; } 11 if(x3>x4) 12 { t=x4; x4=x3; x3=t; } 13 if(y3>y4) 14 { t=y4; y4=y3; y3=t; } 15 a=x1-x4>x3-x2?x1-x4:x3-x2; 16 b=y1-y4>y3-y2?y1-y4:y3-y2; 17 if(a>=0||b>=0) printf("0.00\n"); 18 else printf("%.2f\n", a*b); 19 } 20 return 0; 21 }
//
1 #include<stdio.h> 2 int main() 3 { 4 double x1,y1, x2,y2, x3,y3, x4,y4, a,b, t; 5 while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4)!=EOF) 6 { 7 if(x1>x2) 8 { t=x2; x2=x1; x1=t; } 9 if(y1>y2) 10 { t=y2; y2=y1; y1=t; } 11 if(x3>x4) 12 { t=x4; x4=x3; x3=t; } 13 if(y3>y4) 14 { t=y4; y4=y3; y3=t; } 15 a=(x2<x4?x2:x4)-(x1>x3?x1:x3); 16 b=(y2<y4?y2:y4)-(y1>y3?y1:y3); 17 if(a<0||b<0) printf("0.00\n"); 18 else printf("%.2f\n", a*b); 19 } 20 return 0; 21 }
标签:isp case 没有 tput positive nts 智商 can ted
原文地址:https://www.cnblogs.com/goldenretriever/p/10355783.html