import java.util.*;
import java.io.*;
public class Conversion
{
public static void main(String[] args)
{
try{
int N,d,c,result;
String res=new String();
Stack s=new Stack();
System.out.println("Please Input N");
N=System.in.read();
System.out.println("please Input d");
d=System.in.read();
while ((c=System.in.read())=='\n')
{
while (N!=0)
{
result=N%d;
s.push(new Integer(result));//这里老是报错,该如何解决
N=N/d;
}
}
while (!s.isEmpty())
{
res=s.pop().toString();
System.out.println(res);
}
}catch(IOException e){
System.out.println(e);}
}
}
没有错误了
import java.io.*;
public class Conversion
{
public static void main(String[] args)
{
try{
int N,d,c,result;
String res=new String();
Stack s=new Stack();
System.out.println("Please Input N");
N=System.in.read();
System.out.println("please Input d");
d=System.in.read();
while ((c=System.in.read())=='\n')
{
while (N!=0)
{
result=N%d;
s.push(new Integer(result));//这里老是报错,该如何解决
N=N/d;
}
}
while (!s.isEmpty())
{
res=s.pop().toString();
System.out.println(res);
}
}catch(IOException e){
System.out.println(e);}
}
}
没有错误了
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货