问题描述
import java.util.*;
import java.lang.*;
import java.io.*;
class GFG {
public static void main (String[] args) throws java.lang.Exception {
//code
BufferedReader br=new BufferedReader(new InputStreamReader(system.in));
StringTokenizer st=new StringTokenizer(br.readLine());
int qu=Integer.parseInt(br.readLine());
while(qu-- >0)
{
int n=Integer.parseInt(br.readLine());
String[] s = br.readLine().trim().split("\\s+");
int arr[]=new int[n];
long prod=1;
for(int i=0;i<n;i++)
{arr[i]=Integer.parseInt(s[i]);
prod*=arr[i];
}
for(int i=0;i<n;i++)
{
System.out.print(prod/arr[i]+" ");
}
System.out.println();
}
}
}
这是我的代码,我想输入以下内容: (我正在使用\ n显示“ enter”键) 1 \ n 5 \ n 10 3 5 6 2
我得到了这个例外:
运行时错误:
线程“ main”中的运行时ErrorException java.lang.NumberFormatException:对于输入字符串:“ 10 3 5 6 2” 在java.base / java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) 在java.base / java.lang.Integer.parseInt(Integer.java:652) 在java.base / java.lang.Integer.parseInt(Integer.java:770) 在GFG.main(File.java:15)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)