package study; import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; public class test2 {     public static void main(String[] args) {         Scanner scanner = new Scanner(System.in);         String str1 = scanner.nextLine();         String[] arr1=str1.split(" ");         String str2 = scanner.nextLine();         String[] arr2=str2.split(" ");         String str = scanner.nextLine();         String temp;         Queue<String> queue = new LinkedList<String>();         queue.offer(str);         int n = 1;         while(queue.size()>0) {             temp = queue.poll();                 for (int i = 0; i < arr2.length; i++) {                 if(temp.equals(arr2[i])) {                     n=n+1;                     queue.offer(arr1[i]);                 }             }         }         System.out.println(n);     } } 第一题测试代码都过了,但是ac一直为0很纳闷
点赞 1

相关推荐

VirtualBool:都去逗他了?
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务