acm java提交后运行错误,在编译器中运行正确
importjava.util.Scanner;publicclassMain{Strings;publicstaticvoidmain(String[]args){Ma...
import java.util.Scanner;
public class Main {
String s;
public static void main(String[] args) {
Main m=new Main();
Scanner sr=new Scanner(System.in);
int n=sr.nextInt();
for(;n>0;--n){m.setS();m.sc(m.s);}
}
public void setS(){
Scanner sr=new Scanner(System.in);
s=sr.nextLine();
}
public void sc(String s)
{
char a[]=s.toCharArray();
for(int c=0;c<a.length;++c){
if(a[c]==' ')
System.out.print(',');
else
System.out.print(a[c]);}
}
}
/**************************************************************
Problem: 1089
User: 14110600526
Language: Java
Result: 运行错误
****************************************************************/ 展开
public class Main {
String s;
public static void main(String[] args) {
Main m=new Main();
Scanner sr=new Scanner(System.in);
int n=sr.nextInt();
for(;n>0;--n){m.setS();m.sc(m.s);}
}
public void setS(){
Scanner sr=new Scanner(System.in);
s=sr.nextLine();
}
public void sc(String s)
{
char a[]=s.toCharArray();
for(int c=0;c<a.length;++c){
if(a[c]==' ')
System.out.print(',');
else
System.out.print(a[c]);}
}
}
/**************************************************************
Problem: 1089
User: 14110600526
Language: Java
Result: 运行错误
****************************************************************/ 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询