参考代码:
#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; } 我写成这样就算格式错误是个什么情况??
printf基础练习2 (C语言代码)浏览:603 |
C语言训练-求素数问题 (C语言代码)浏览:1502 |
C语言程序设计教程(第三版)课后习题8.9 (Java代码)浏览:1390 |
简单的a+b (C语言代码)浏览:593 |
出圈】指针malloc版浏览:373 |
循环入门练习6 (C语言代码)浏览:1030 |
1054题解浏览:508 |
输入输出格式练习 (C语言代码)浏览:881 |
C语言程序设计教程(第三版)课后习题6.8 (C语言代码)浏览:651 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:525 |