package com.nbuf; import java.util.Scanner; public class DemoScanner { public static int judge(int num){ if(num>1){ if(num==1){ return num; }else { num--; num=judge(num); } }else if(num<1){ if(num==1){ return num; }else { num++; num=judge(num); } }else { return num; } return num; } public static void main(String[] args) { Scanner scanner=new Scanner(System.in); System.out.print("请输入 一个整数:"); int num=scanner.nextInt(); int num1=judge(num); System.out.println(num1); scanner.close(); } }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)