# 算数题,该怎么处理

www.MyException.Cn  网友分享于：2013-02-02  浏览：7次

------解决方案--------------------
Java code
```        String s = Integer.toString(728, 3);
byte[] bytes = s.getBytes();
for(int i = 0; i < bytes.length; i++){
System.out.println(bytes[i]);
bytes[i] = (byte)(bytes[i] + 17);
}
System.out.println(new String(bytes));
------解决方案--------------------for exampleJava codepublic class csdn {
public static void main(String[] args) throws Throwable {
String s = "222222";
System.out.println(Integer.parseInt(s, 3));
System.out.println(toString(728, 3));
}

public static String toString(int n, int radix) {
char[] dig = {'A', 'B', 'C'};
if (radix > dig.length) {return "100000";}
StringBuilder buf = new StringBuilder();
for (char c : s.toCharArray()) {
buf.append(dig[c-'0']);
}
return buf.toString();
}
}
------解决方案-------------------- String s = Integer.toString(728, 3);       byte[] bytes = s.getBytes();       for(int i = 0; i < bytes.length; i++){           System.out.println(bytes[i]);           bytes[i] = (byte)(bytes[i] + 17);       }       System.out.println(new String(bytes));
------解决方案--------------------[code=Java][/code]System.out.println("输入要处理的数字（最大值728）：");		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));		String s = br.readLine();		Integer co = Integer.parseInt(s);		if(co <= 728){			String ss = Integer.toString(co, 3);			byte[] by = ss.getBytes();			for(int i=0; i<by.length; i++){				by[i] = (byte)(by[i] + ('A' - '0'));			}			System.out.println(new String(by));		}else			System.out.println("请输入不大于728的数！");
------解决方案--------------------Java code
System.out.println("输入要处理的数字（最大值728）：");
Integer co = Integer.parseInt(s);
if(co <= 728){
String ss = Integer.toString(co, 3);
byte[] by = ss.getBytes();
for(int i=0; i<by.length; i++){
by[i] = (byte)(by[i] + ('A' - '0'));
}
System.out.println(new String(by));
}else
System.out.println("请输入不大于728的数！");```