import java.io.*;class horse
{
 int setcolor(int col)
 {
   return 625356-col;
 }
 int getcolor(int col)
 {
  return setcolor(col);
 }
}
class mr
{
 public static void main(String args[])
 {
  int ot;
  horse hr;
  hr=new horse();
  try
  {
  System.out.println("Äã±ØÐèÊäÈëÒ»¸öÕûÊý£º");
  //ÐÞ¸Ä
  String str;
  BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
  str=in.readLine();
  int cc = Integer.parseInt(str);
  //end
  ot=hr.getcolor(cc);
  System.out.println(ot);
  System.out.println(System.currentTimeMillis());
 }
  catch(Exception e)
  {}
 }
}

解决方案 »

  1.   

    System.in.read();读进来的是流中下一个byte,再转成0到255间的整数。输入56、57读进来的都是代表5的那个byte,转成整数是53,所以结果是625303。
      

  2.   

    修改import java.io.*;class horse
    {
     int setcolor(int col)
     {
       return 625356-col;
     }
     int getcolor(int col)
     {
      return setcolor(col);
     }
    }
    class mr
    {
     public static void main(String args[])
     {
      String cc;
      int ot;
      horse hr;
      hr=new horse();
      try
      {
      System.out.println("你必需输入一个整数:");
      BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
      cc=in.readLine();
      ot=hr.getcolor(Integer.parseInt(cc));
      System.out.println(ot);
      System.out.println(System.currentTimeMillis());
     }
      catch(Exception e)
      {}
     }
    }
      

  3.   

    cc=System.in.read();//这里只会读取一个字符,所以56,57就是返回'5'
    这里要改成
    BufferReader br = new BufferReader(new InputStreamReader(System.in));
    String line = br.readLine();
      cc = Integer.parseInt(line);
      

  4.   

    打印出cc看看是多少就知道为什么了。
      System.out.println("你必需输入一个整数:");
      cc=System.in.read();
      System.out.println("输入了:" + cc);
      

  5.   

    cc=System.in.read();
    读到的是第一个字符的ascii数值
    56/57地一个都是'5' ascii = 53
    所以得到6253032ascii = 50
    所以得到625306
      

  6.   

    625356已经超出int的范围了……
      

  7.   

    to tsing_liu,int是4为的,你看看有多大。。
      

  8.   

    Thank you very much!
    我试了试,的确是只读入了一个byte,所以他的值永远都不会大于255,天那!我终于明白了!太谢谢各位了!
      

  9.   

    我听说过,考Java的认证题中,有很多就是这么样的小问题,其实这是细节性的问题,但是如果不注意的话,哈哈,往往就会出错的,所以,以后我会小心行事的,决不能在小水沟里番了大船1