public class Test {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入人数 :");
int num = sc.nextInt();
int BuyNumber = 0;
if(num <= 3){
BuyNumber = num;
}
else {
for(int x = 3 ; x <num ; x++){
if(x + x/2 >= num){
if((x%2 == 0)&&(x +x/2 == num)){
BuyNumber = x + 1 ;
break;
}
else {
BuyNumber = x;
break;
}
}
}
}
System.out.println(BuyNumber);
}
} |