/**
-
此程序为扑克牌洗牌程序
/
import java.util.Random;
import java.util.;
public class Debug{
public static void main(String[] args){
int count;int k=54; //扑克牌数 int begin=0; //开始拥有扑克牌数 int end =54; //剩余扑克牌数 String a[]=suiji(k,begin,end); //调用方法 count=0; for(int i=0;i<k;i++){ System.out.print(a[i]+" "); //输出suiji方法 count++; if(/*count/12>=1&&*/count%12==0){ //分行黑桃,红桃,方块,梅花 System.out.print(" ");// } }
}
public static String[] suiji(int k,int begin,int end){String arr[] = new String[100]; int res; String[] values=new String[]{"黑桃A","黑桃A","黑桃2","黑桃3","黑桃4","黑桃5","黑桃6","黑桃7","黑桃8","黑桃9","黑桃10","黑桃J","黑桃Q","黑桃K","红桃A","红桃2", "红桃3","红桃4","红桃5","红桃6","红桃7","红桃8","红桃9","红桃10","红桃J","红桃Q","红桃K","梅花A","梅花2","梅花3","梅花4","梅花5","梅花6","梅花7","梅花8","梅花9", "梅花10","梅花J","梅花Q","梅花K","方块A","方块2","方块3","方块4","方块5","方块6","方块7","方块8","方块9","方块10","方块J","方块Q","方块K","大王","小王"}; //转载
/int cunchu[] = new int[100];
cunchu[0]=1;
for(int i=1;i<100;i++){
cunchu[i]=0;
}
Random r = new Random(); //设置r为随机数
for(int i=0;i<k;i++){
res = r.nextInt(end-begin)+begin; //end于begin本想作为补充,不过已经达到目的就不动了
//while(cunchu[res]==1){ //避免跳过第一张牌,事实上这一步是多余的
//res = r.nextInt(end-begin)+begin+1;
//}
arr[i]=values[res];
cunchu[res]=1;
}
return arr;
}/
Random yok=new Random(); //自己尝试完成洗牌的最简程序
for(int i=0;i<k;i++){
res=yok.nextInt(end); //核心:产生54内随机数,使扑克牌从第一位开始任意掉换,达到洗牌的目的
arr[i]=values[res];
}
return arr;}
}