poj2719

把各个位上的大于4的数都减一, 例如:15变成14,67变成56.然后把这个数字当成是9进制,用java转为10进制输出。

View Code
   
     
import java.util. * ;
import java.io. * ;
import java.math. * ;

public class Main {
public static void main(String[] args) {
Scanner cin
= new Scanner( new BufferedInputStream(System.in));
while (cin.hasNext())
{
String st
= cin.nextLine();
if (st.equals( " 0 " ))
break ;
char st1[] = st.toCharArray();
for ( int i = 0 ; i < st1.length; i ++ )
{
if (st1[i] > ' 4 ' )
st1[i]
-- ;
}
String st2
= new String(st1);
int num = Integer.parseInt(st2, 9 );
System.out.println(st
+ " : " + num);
}
}
}

你可能感兴趣的:(poj)