参考代码:
#include<stdio.h> #define max(x,y) ((x)>(y)?(x):(y)) #define min(x,y) ((x)<(y)?(x):(y)) int main(){ double x1,y1,x2,y2; //矩形1 double x3,y3,x4,y4; //矩形2 double m1,n1; //交集左上角坐标. double m2,n2; //交集右下角坐标. scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2); scanf("%lf%lf%lf%lf",&x3,&y3,&x4,&y4); m1 = max(min(x1,x2),min(x3,x4)); n1 = max(min(y1,y2),min(y3,y4)); m2 = min(max(x1,x2),max(x3,x4)); n2 = min(max(y1,y2),max(y3,y4)); if(m2>m1 && n2>n1) printf("%.2f\n",(m2 - m1)*(n2 - n1)); else printf("0.00\n"); return 0; }
0.0分
9 人评分
#include <stdio.h> #define max(x,y) ((x)>(y)?(x):(y)) #define min(x,y) ((x)<(y)?(x):(y)) int main() { double x1,y1,x2,y2; double x3,y3,x4,y4; double m1,n1; double m2,n2; scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2); scanf("%lf%lf%lf%lf",&x3,&y3,&x4,&y4); printf("\n"); m1=max(min(x1,x2),min(x3,x4)); n1=max(min(y1,y2),min(y3,y4)); m2=min(max(x1,x2),max(x3,x4)); n2=min(max(y1,y2),max(y3,y4)); if(m2>m1 && n2>n1) printf("%.2f\n",(m2 - m1)*(n2 - n1)); else printf("0.00\n"); return 0; } 我写成这样就算格式错误是个什么情况??
C语言程序设计教程(第三版)课后习题6.10 (C语言代码)浏览:1090 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:512 |
A+B for Input-Output Practice (V) (C语言代码)浏览:497 |
A+B for Input-Output Practice (VII) (C语言代码)浏览:566 |
1118(求助_已解决)浏览:351 |
剪刀石头布 (C++代码)浏览:1811 |
C语言程序设计教程(第三版)课后习题11.5 (C语言代码)浏览:1495 |
钟神赛车 (C语言代码)浏览:665 |
交换Easy (C语言代码)浏览:805 |
字符串比较 (C语言代码)浏览:770 |