解题思路:全部转换为大写字母求和然后判断是否相等就行了。
注意事项:
参考代码:
import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Scanner; import javax.swing.Box; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String s1 = scanner.next();String s2 = scanner.next(); int sum1 = 0; int sum2 =0; char[] ch1 = s1.toCharArray();char[] ch2 = s2.toCharArray(); for (int i = 0; i < ch1.length; i++) { if (ch1[i]>= 65 && ch1[i]<=90) { sum1+=ch1[i]; } else { sum1+=ch1[i]-32; } } for (int i = 0; i < ch2.length; i++) { if (ch2[i]>= 65 && ch2[i]<=90) { sum2+=ch2[i]; } else { sum2+=ch2[i]-32; } } if (sum1 == sum2) { System.out.println("Y"); } else { System.out.println("N"); } } }
0.0分
3 人评分