java一个彩票算法的问题

2022-11-11 21:04发布

import java.util.Scanner; public class Test { public int getAgo(){ Scanner

import java.util.Scanner; public class Test { public int getAgo(){ Scanner
5条回答
2022-11-11 21:35

import java.util.Scanner;

public class Test {
public int getAgo(){
Scanner sc = new Scanner(System.in);
System.out.println("请输入已买过的注数!");
int a = sc.nextInt();
return a ;
}
public int number(int a){
int num = 0;
while((a+num)*2>=5*num){
num++;
}
return num;
}
public static void main(String[] args){
Test t = new Test();
int a = t.getAgo();
System.out.println("下次需要买"+t.number(a)+"注不亏");
}
}