eclipse 默认在*.java首行添加
package projectname;
导致RTE
模板 poj1311
import java.util.*;
import java.io.*;
import java.math.*;
public class Main {//这里Main
public static void main(String[] args) {//这里main
// TODO Auto-generated method stub
Scanner cin = new Scanner (new BufferedInputStream(System.in));
while(cin.hasNext()){
String s;
s=cin.nextLine();
BigDecimal ans,tmp;
tmp=new BigDecimal("1");
ans=new BigDecimal("0");
BigDecimal eig=new BigDecimal("8");
for(int i=s.indexOf('.')+1;i<s.length();i++){
tmp=tmp.divide(eig);
//System.out.println(new BigDecimal(s.charAt(i)-'0').multiply(tmp));
ans=ans.add(new BigDecimal(s.charAt(i)-'0').multiply(tmp));
}
System.out.println(s+" [8] = "+ans+" [10]");
}
}
函数sample
//AC
package poj1504;
import java.io.*;
import java.util.*;
import java.math.*;
public class Main {
public static String reverse (String orig)
{
String rslt="";
int len=orig.length();
for(;orig.charAt(len-1)=='0';len--);
for(int i=len-1;i!=-1;i--)
{
rslt=rslt+orig.charAt(i);
}
return rslt;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner cin =new Scanner(new BufferedInputStream(System.in));
BigInteger orig1,orig2,rslt;
String rvs;
int n;
while(cin.hasNext())
{
n=cin.nextInt();
for(int roundcount=0;roundcount<n;roundcount++)
{
orig1=cin.nextBigInteger();
orig2=cin.nextBigInteger();
orig1=new BigInteger(reverse(orig1.toString()));
orig2=new BigInteger(reverse(orig2.toString()));
rslt=orig1.add(orig2);
System.out.println(reverse(rslt.toString()));
}
}
}
}
语句变化(与CPP相比)
bool -> boolean//仅仅接受false&true
while()内只接受true/false
true/false和数之间不能转化