第六次作业
2016-05-12 09:03
337 查看
package xq;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;
public class choujiang {
ArrayList cards;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;
public class choujiang {
ArrayList cards;
public ArrayList<Integer> deal(){ if(cards==null){ cards = new ArrayList<Integer>(); for(int i =1;i<100;i++){ cards.add(i); } } Collections.shuffle(cards); return cards; } public void play(){ Random r = new Random(); int a = r.nextInt(100); System.out.println("一等奖:"+ cards.get(a)+"号"); cards.remove(a); for(int i=1;i<=3;i++){ a = r.nextInt(100); System.out.println("二等奖:"+cards.get(a)+"号"); cards.remove(a); } } public static void main(String[] args) { choujiang a=new choujiang(); a.deal(); a.play(); }
相关文章推荐
- 《剑指offer》-栈的压入、弹出序列
- PropertyPlaceholderConfigurer的用法
- Binder
- Spring MVC的RequestParam注解
- 12 个非常有用的 JavaScript 技巧
- BroadcastReceiver源码解析(一)
- 创业的第一百八十天
- cannot return from outside a function or method
- Python基于二分查找实现求整数平方根的方法
- STM32F1和STM32F4 区别
- pyte模块
- 《Linux驱动》最简单的驱动编写与makefile
- Myeclipse中SVN版本与客户端版本出现冲突问题与解决方法
- jquery ajax局部加载方法详解(实现代码)
- Twitter-Snowflake,64位自增ID算法详解
- java字符串的操作
- 第一篇博文
- android JNI调用机制
- location.href 与 location.search
- android JNI调用机制