怎么用random生成6个数字(1-45),,

[复制链接]
查看11 | 回复1 | 2010-4-6 12:45:51 | 显示全部楼层 |阅读模式
public class test{public static void main(String []arrr){Random r=new Random();int l1=r.nextInt()%45+1;int l2=r.nextInt()%45+1;int l3=r.nextInt()%45+1;int l4=r.nextInt()%45+1;int l5=r.nextInt()%45+1;int l6=r.nextInt()%45+1;System.out.println("l1 ="+l1+"l2 ="+l2+"l3 ="+l3+"l4 ="+l4+"l5="+l5+"l6 ="+l6);}}
回复

使用道具 举报

千问 | 2010-4-6 12:45:51 | 显示全部楼层
import java.util.Random;public class Test{ public static void main(String []arrr){ Random r=new Random(); int l1=r.nextInt(45)+1; int l2=r.nextInt(45)+1; int l3=r.nextInt(45)+1; int l4=r.nextInt(45)+1; int l5=r.nextInt(45)+1; int l6=r.nextInt(45)+1; System.out.println("l1 ="+l1+";l2 ="+l2+";l3 ="+l3+";l4 ="+l4+";l5="+l5+";l6 ="+l6); } }
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行