import java.util.*;
public class KZTinputArray {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Pls input a string:");
String str = in.nextLine();
// int a[] = new int[str.length()];
/*
* for (int i = 0; i < str.length(); i++) { a[i] = str.charAt(i) - '0';
* }
*/
char[] a = str.toCharArray();
for (int i = a.length-1; i >=0; i--) {
System.out.print(a[i] + "\t");
}
}
}
采纳哈!!!
在键盘上输入随意三位数得到值a
算法如下,反向输出的个位十位和百位
x=个位=a/100
y=十位=a%100/10
z=百位=((a%100)%10)
system.out.print(z*100+y*10+x)
import java.util.Scanner;
public class Test{
public static void main(String[]args){
Scanner ss=new Scanner(System.in);
System.out.println("请输入3位整数");
String num=ss.next();
int numLength=num.length();
if(numLength!=3){
System.out.println("请输入正确的3位整数!");
}else{
char temp[]=new char[numLength];
for(int i=0;i
}
for(int i=0;i
int num2=(int)temp[j];
if(num1>num2){
num1=num1+num2;
num2=num2-num1;
num2=num1+num2;
temp[i]=num1;
temp[j]=num2;
}
}
}
for(int i=0;i
}
}
}
}
将3为整数变成一个string,然后从最后提取就行了
public class ReverseDemo{
public static void main(String args[])
{
String a1=args[0];
StringBuffer na=new StringBuffer(a1);
System.out.println("The reversed string is: "+na.reverse());
}
}