输入字符后没结果也没报错

img

img

img

我的代码:

import java.util.*;
public class Main06 {
public static void main(String[] args) {
Scanner inLine = new Scanner(System.in);

    int[] data;
    int N=0,M=0,Input=0,geshu=0;
    String T="";
    String commandLine1="",commandLine2="",actionLines="";

    while (inLine.hasNext()){
        commandLine1 = inLine.nextLine();
        Scanner inNum = new Scanner(commandLine1);
        N=inNum.nextInt();
        data=new int[N];
        M=inNum.nextInt();
        inNum.close();
        
        commandLine2=inLine.nextLine();
        Scanner inArray =new Scanner(commandLine2);
        for(int i=0;i<N;i++) {
            data[i]=inArray.nextInt();
        }
        inArray.close();
        
        for ( int n =0 ; n < M ; n++){
            actionLines = inLine.nextLine();
            Scanner sc = new Scanner(actionLines);
            T=sc.next();
            Input=sc.nextInt();
            
            if ( T.equals( "A" )){
                for ( int j =0 ; j < N ;j++){
                    data[j]=(data[j]+Input)%100;
                }
            }
            
            if ( T == "Q" ){
                for ( int j =0 ; j < N ;j++){
                    if ( data[j] % 10 == Input )
                        geshu++;    
                }
            System.out.println(geshu);
            }
        }
    }
}

}

我的运行结果:

img

想问问为什么他还是提示输入,就是不出结果来着,也没有报错

你看程序有没有结束,可能死循环了。

因为你代码里太多循环里要求输入了啊
你自己调试代码的时候,多写print,每一步都要能看到结果,都调试好了再删除print
要么就加断点单步调试
不要让自己的代码跟个黑盒子一样,还得靠猜