Java 褪色回文运行时错误
这是一个codechef程序。。基本上,它在我的本地机器上运行良好,我也尝试了所有的在线编译器,但codechef不断给我运行时错误 链接- 请帮我弄清楚错误是什么 运行时错误为RE(NZEC)Java 褪色回文运行时错误,java,runtime,Java,Runtime,这是一个codechef程序。。基本上,它在我的本地机器上运行良好,我也尝试了所有的在线编译器,但codechef不断给我运行时错误 链接- 请帮我弄清楚错误是什么 运行时错误为RE(NZEC) import java.util.*; 班级退色 { 公共静态void main(字符串参数[]) { 显示(); } 公共静态无效显示() { Scanner get=新扫描仪(System.in); int n=get.nextInt(); 字符串结果[]=新字符串[n]; String readu
import java.util.*;
班级退色
{
公共静态void main(字符串参数[])
{
显示();
}
公共静态无效显示()
{
Scanner get=新扫描仪(System.in);
int n=get.nextInt();
字符串结果[]=新字符串[n];
String readuser[]=新字符串[n];
get.nextLine();
对于(int a=0;a而言,当字符串中出现多个“.”时,需要满足一些轻微的逻辑测试用例。请检查这些。
关于在display()函数中解析NZEC,您需要捕获一个异常,然后NZEC错误就会消失
建议您使用BufferReader、InputStreamReader除非您提供运行时错误的详细信息,否则我们无法为您提供帮助。运行时错误为RE(NZEC)
import java.util.*;
class Faded
{
public static void main (String args[])
{
display();
}
public static void display()
{
Scanner get=new Scanner(System.in);
int n=get.nextInt();
String result[]= new String[n];
String readuser[]= new String[n];
get.nextLine();
for(int a=0;a<n;a++)
{
readuser[a]=get.nextLine();
}
for(int a=0;a<n;a++)
{
result[a]=new String(readuser[a]);
if((readuser[a].length()==3)&&(readuser[a].charAt(0)!=readuser[a].charAt(2)))
{
result[a]=new String("-1");
continue;
}
int res=readuser[a].indexOf(".");
float mid=(readuser[a].length())/2;
if((res==mid)||(readuser[a].length()==1))
{
result[a]=result[a].replace('.','a');
continue;
}
if(res==readuser[a].length()-1)
{
result[a]=result[a].replace('.',result[a].charAt(0));
continue;
}
if(res<readuser[a].length()/2)
{
result[a]=result[a].replace('.',result[a].charAt(readuser[a].length()-1-res));
}
else
{
result[a]=result[a].replace('.',result[a].charAt(res+1));
}
}
for(int a=0;a<n;a++)
System.out.println(result[a]);
}
}