解题思路:
注意事项:
本题解在eclipse上运行无误,但是在这里运行显示运行错误,(仅供参考)
参考代码:
import java.util.Scanner;
import java.text.DecimalFormat;
public class Main {
public static void Rect(int[] arrayA,int[] arrayB){
DecimalFormat df = new DecimalFormat("0.00");
if(arrayB[0]>arrayA[2]||arrayB[1]>arrayA[3])
System.out.println("两矩形没有相交!");
else
System.out.print(df.format((arrayA[3]-arrayB[1])*(arrayA[2]-arrayB[0])));
}
public static void main(String[] arg){
Scanner sc = new Scanner(System.in);
int[] arrayA = new int[4];
int[] arrayB = new int[4];
for(int i=0;i<4;i++){
arrayA[i] = sc.nextInt();
}
for(int i=0;i<4;i++){
arrayB[i] = sc.nextInt();
}
Rect(arrayA, arrayB);
}
}
0.0分
2 人评分
C语言训练-数字母 (C语言代码)浏览:571 |
C语言训练-求素数问题 (C语言代码)浏览:687 |
【偶数求和】 (C语言代码)浏览:571 |
WU-printf基础练习2 (C++代码)浏览:1956 |
printf基础练习2 (C语言代码)浏览:620 |
2004年秋浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:483 |
母牛的故事 (C语言代码)浏览:1375 |
求圆的面积 (C语言代码)浏览:1600 |
C二级辅导-等差数列 (C语言代码)浏览:672 |
字符逆序 (C语言代码)浏览:598 |