java编程怎么完成任意输入一个正整数,反序输出每一位?
1个回答
展开全部
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("输入任意正整数:");
StringBuffer sb = new StringBuffer(input.next());
sb.reverse();
System.out.print("逆序为:");
System.out.println(sb);
}
Scanner input = new Scanner(System.in);
System.out.print("输入任意正整数:");
StringBuffer sb = new StringBuffer(input.next());
sb.reverse();
System.out.print("逆序为:");
System.out.println(sb);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询