| 查看: 369 | 回复: 2 | |||
| 当前主题已经存档。 | |||
[交流]
【求助】坐等大侠指点 已有2人参与
|
|||
|
import java.util.Random; import java.lang.System; public class poker { public static void main(String arg[]) { int temp; //做一副扑克牌 int []poke; poke=new int[48]; int i,j,k; k=0; for(i=0;i<4;i++) { for(j=0;j<12;j++) { poke[k]=j+1; k++; } }//做一副扑克牌 //洗牌 Random myRandomInstance; myRandomInstance=new Random(); for(k=0;k<2000;k++) { i=myRandomInstance.nextInt(48); j=myRandomInstance.nextInt(48); temp=poke; poke=poke[j]; poke[j]=temp; }//洗牌 //发牌 int [][]plane; plane=new int[8][12]; k=0; for(i=0;i<4;i++) for(j=0;j<12;j++) { plane[j]=poke[k]; k++; } for(i=4;i<8;i++) for(j=0;j<12;j++) { plane[j]=0; } // System.out.print(k) for(i=0;i<8;i++) { for(j=0;j<12;j++) { System.out.print(plane[j]+" " ;}//发牌 System.out.println(); } //玩牌 int []upper; int []down; upper=new int [12]; down=new int [12]; for(j=0;j<12;j++) { upper[j]=0; down[j]=4; } temp=plane[0][0];upper[0]+=1; while(down[0]<7) { plane[(down[temp-1])][temp-1]=temp; System.out.print(temp); (down[temp-1])++; if(down[0]<7) { temp=plane[upper[temp-1]][temp-1]; (upper[temp-1])++; } } for(i=4;i<8;i++) { for(j=0;j<12;j++) { System.out.print(plane[j]+" " ;}//玩牌 System.out.println(); } } } 调试到那儿出错了,显示数组越界怎么回事? |
» 猜你喜欢
征友后感触
已经有10人回复
考博求助
已经有4人回复
憎水剂,表面活性剂
已经有3人回复
申博
已经有7人回复
食品与机械 编辑C处理稿子时间
已经有4人回复
注意啦!用基金购买打印纸、硒鼓、优盘、移动硬盘、个人计算机属于违规了
已经有4人回复

2楼2010-04-06 16:05:41
3楼2010-04-07 13:36:06










;
回复此楼