【美团笔试】
太搞笑了,两个都是钻空子,要是能钻空子拿offer就好了
一、大数相加,用BigInteger就是要注意解决输入为空串的情况,不然只有91%
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String s1 = sc.nextLine();
String s2 = sc.nextLine();
if(s1 == null || s1.length() == 0)
System.out.println(s2);
else if(s2 == null || s2.length() == 0)
System.out.println(s1);
else {
BigInteger a = new BigInteger(sc.nextLine());
BigInteger b = new BigInteger(sc.nextLine());
System.out.println(a.add(b));
}
} 二、发激励,题目太长了,要多线程我都看懵了,想试试直接输出,结果过了。。。 public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
for(int i = 1;i<=n;i++){
if(i %2 ==1)
System.out.print("A");
else if(i %4 == 2)
System.out.print("B");
else
System.out.print("C");
}
}
查看8道真题和解析