贝壳网笔试

import java.util.*; public class Demo44 { public static void main(String[] args){
    Scanner sc = new Scanner(System.in); int T= sc.nextInt();    for(int i=0;i<T;i++){  str=sc.nextLine().split(" ");  if(str.length==4) find(str);  }
} public static void find(String[] str){ int countLeft=0;  int countRight=0;  if(compare(str[0],str[2])) countLeft+=1;  if(compare(str[1],str[2])) countRight+=1;  if(compare(str[0],str[3])) countLeft+=1;  if(compare(str[1],str[3])) countRight+=1;  if(countLeft>countRight) System.out.println("left");  if(countRight>countLeft) System.out.println("right");  if(countLeft==countRight) System.out.println("same");   } public static boolean compare(String a, String b){ if(a.equals(b)) return false;  else if (a.equals("J")&&b.equals("S")) return false;  else if(a.equals("S")&&b.equals("B")) return false;  else if(a.equals("B")&&b.equals("J")) return false;  else return true;  }
}
想问问大家我的这个输入处理的哪里有问题呀,为什么刚输入完第一行数据就会自动跳走呢?谢谢#笔试题目##贝壳找房#
全部评论
好像是要在读取下一行字符串前把行读了,加个sc.nextline再读字符串
点赞 回复 分享
发布于 2020-09-07 17:31

相关推荐

不愿透露姓名的神秘牛友
昨天 15:37
点赞 评论 收藏
分享
06-07 19:59
门头沟学院 C++
补药卡我啊😭:都快15年前的了还在11新特性
你的简历改到第几版了
点赞 评论 收藏
分享
06-13 10:15
门头沟学院 Java
想去夏威夷的大西瓜在...:我也是27届,但是我现在研一下了啥项目都没有呀咋办,哎,简历不知道咋写
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务