packagehuawei;publicclassNumberInverse{privateintamount=0;privateStringstringOutput="";privateintinverseInt=0;publicNumberInverse(intinput){Stringstr=input+"";if("-".equa...
package huawei;
public class NumberInverse{
private int amount=0;
private String stringOutput="";
private int inverseInt=0;
public NumberInverse(int input) {
String str = input + "";
if ("-".equals(str.substring(0, 1)))
{
} else
{
this.amount = str.length();
}
for(int i=0;i
{
this.stringOutput+=str.charAt(i)+" ";
}
String temp="";
if ("-".equals(str.substring(0, 1)))
{
temp="-";
for(int i=str.length()-1;i>0;i--)
{
temp+=str.charAt(i);
}
}
else
{
for(int i=str.length()-1;i>=0;i--)
{
temp+=str.charAt(i);
}
}
this.inverseInt=Integer.parseInt(temp);
}
public int getAmount()
{
return amount;
}
public String getStringOutput()
{
return stringOutput;
}
public int getInverseInt()
{
return inverseInt;
}
public static void main(String[] args)
{
NumberInverse test = new NumberInverse(23456);
System.out.println(test.getAmount());
System.out.println(test.getStringOutput());
System.out.println(test.getInverseInt());
}
}
展开