描述:
输入一个整数,将这个整数以字符串的形式逆序输出
程序不考虑负数的情况,若数字含有0,则逆序形式也含有0,如输入为100,则输出为001
package 牛客;
import java.util.Scanner;
public class 数字颠倒 {
public static void main(String[] args) {
Scanner s= new Scanner(System.in);
String str=s.nextLine();
StringBuffer sb=new StringBuffer(str);
sb.reverse();
System.out.println(sb);
}
}
package 牛客;
import java.util.*;
public class 数字颠倒1{
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
int num=s.nextInt();
String str="";
while(num!=0) {
int a=num%10;
int b=num/10;
str=str+String.valueOf(a);
num=b;
}
System.out.println(str);
}
}