import java.util.Random; /*对10位同学进行抽奖:一等奖1名,二等奖2名,三等奖3名,不得重复获奖,输出各类奖项获奖人员名单 */ public class Test2 { public static void main(String[] args) { String[] persons = new String[]{"王小花","谭小花","陈小花","汤小花","杨小花","徐小花", "李小花","吴小花","唐小花","胡小花"}; boolean[] b = new boolean[]{false,false,false,false,false,false,false,false,false,false}; Random r = new Random(); int i1 = r.nextInt(10); String[] s1 = new String[1]; s1[0] = persons[i1]; b[i1] = true; System.out.println("恭喜,抽中的一等奖为:" + s1[0]); int i2; String[] s2 = new String[2]; for(int i = 0;i < 2;i++){ i2 = r.nextInt(10); if(!b[i2]){ s2[i] = persons[i2]; b[i2] = true; }el
08-09
1517
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)