java样例过了但还是不行
查看原帖
java样例过了但还是不行
487734
Time_traveller楼主2021/6/22 23:47
import java.util.*;
import java.io.BufferedInputStream;
public class Main {
        public static void main(String[] args) {
        	Scanner sc = new Scanner(new BufferedInputStream(System.in));
        	 String a = sc.nextLine();
        	 String sen = sc.nextLine();
        	 String e [] = sen.split(" ");
        	 int y = 0;
        	 for(int t = 0;t < e.length;t++) {
            	 boolean c = a.equalsIgnoreCase(e[t]);
            	 if(c == true) {
            	 y++;          	 
            	 }
            	 }
        	 if(y != 0) {
        	 System.out.print(y + " ");
        	 }
        	 for(int p = 0;p < e.length;p++) {
        	 boolean c = a.equalsIgnoreCase(e[p]);
        	 if(c == true) {
        	 System.out.print(p);
        	 break;
        	 }
        	 }
        	 
        	 if(y == 0) {
        		 System.out.println("-1");
        	 }
        }
}	
2021/6/22 23:47
加载中...