- import java.util.ArrayList;
- import java.util.List;
- @SuppressWarnings({ "rawtypes", "unchecked" })
- public class test {
- public static void main(String[] args) {
- List lit = new ArrayList();
- int count = 0;
- while (true) {
- int temp = (int) (Math.random() * 33 + 1);
- if (!lit.toString().contains(String.valueOf(temp))) {
- count++;
- lit.add(temp);
- }
- if (count != 7) {
- continue;
- } else {
- break;
- }
- }
- for (int i = 0; i < 7; i++) {
- System.out.print(lit.get(i) + " ");
- }
- }
- }
复制代码
这样可以实现方式的一种, |