解题思路:
注意事项:
参考代码:
package dotcpp.模拟;
import java.util.Scanner;
public class 矩阵拼接 {
public static void main(String[] args) {
Scanner scanner=new Scanner(System.in);
int n=scanner.nextInt();
while (n>0){
n--;
int a1=scanner.nextInt();
int b1=scanner.nextInt();
int a2=scanner.nextInt();
int b2=scanner.nextInt();
int a3=scanner.nextInt();
int b3=scanner.nextInt();
if(a1==a2){
int side2=b1+b2;
if(a1 ==a3|| a1 ==b3||side2==a3||side2==b3)
System.out.println(4);
else
System.out.println(6);
continue;
}
else if(a1==b2){
int side2=b1+a2;
if(a1 ==a3|| a1 ==b3||side2==a3||side2==b3)
System.out.println(4);
else
System.out.println(6);
continue;
}
else if(b1==a2){
int side2=b2+a1;
if(a2 ==a3|| a2 ==b3||side2==a3||side2==b3)
System.out.println(4);
else
System.out.println(6);
continue;
}
else if(b1==b2){
int side2=a1+a2;
if(b1 ==a3|| b1 ==b3||side2==a3||side2==b3)
System.out.println(4);
else
System.out.println(6);
continue;
}
else if(a2==a3){
int side2=b3+b2;
if(side2 == a1 || side2 == b1)
System.out.println(4);
else
System.out.println(6);
continue;
}
else if(a2==b3){
int side2=b2+a3;
if(side2 == a1 || side2 == b1)
System.out.println(4);
else
System.out.println(6);
continue;
}
else if(b2==a3){
int side2=a2+b3;
if(side2 == a1 || side2 == b1)
System.out.println(4);
else
System.out.println(6);
continue;
}
else if(b2==b3){
int side2=a2+a3;
if(side2 == a1 || side2 == b1)
System.out.println(4);
else
System.out.println(6);
continue;
}
else if(a1==a3){
int side2=b1+b3;
if(side2 == a2 || side2 == b2)
System.out.println(4);
else
System.out.println(6);
continue;
}
else if(a1==b3){
int side2=b1+a3;
if(side2 == a2 || side2 == b2)
System.out.println(4);
else
System.out.println(6);
continue;
}
else if(b1==a3){
int side2=b3+a1;
if(side2 == a2 || side2 == b2)
System.out.println(4);
else
System.out.println(6);
continue;
}
else if(b1==b3){
int side2=a1+a3;
if(side2 == a2 || side2 == b2)
System.out.println(4);
else
System.out.println(6);
continue;
}
int side1=a1+a2;int side2=a3+a2;int side3=a1+a3;
int side4=b1+b2;int side5=b3+b2;int side6=b1+b3;
int side7=b1+a2;int side8=b3+a2;int side9=b1+a3;
int side10=a1+b2;int side11=a3+b2;int side12=a1+b3;
boolean bool1= a3==side1||b3==side1||side2==a1||side2==b1||side3==a2||side3==b2;
boolean bool2= a3==side4||b3==side4||side5==a1||side5==b1||side6==a2||side6==b2;
boolean bool3= a3==side7||b3==side7||side8==a1||side8==b1||side9==a2||side9==b2;
boolean bool4= a3==side10||b3==side10||side11==a1||side11==b1||side12==a2||side12==b2;
if(bool1||bool2||bool3||bool4)
System.out.println(6);
else
System.out.println(8);
}
}
}
0.0分
3 人评分
C语言程序设计教程(第三版)课后习题6.1 (C语言代码)浏览:700 |
ASCII帮了大忙浏览:797 |
C语言程序设计教程(第三版)课后习题3.7 (C语言代码)浏览:467 |
WU-小九九 (C++代码)浏览:1713 |
【矩阵】 (C++代码)浏览:999 |
用筛法求之N内的素数。 (C++代码)浏览:754 |
C二级辅导-阶乘数列 (C语言代码)浏览:583 |
大神老白 (C语言代码)浏览:637 |
多输入输出练习2 (C语言代码)浏览:1710 |
青年歌手大奖赛_评委会打分 (C语言代码)浏览:2248 |
顾小丰 2023-04-06 18:15:59 |
兄弟,真有的,不信你试试