import java.io.*;
import java.util.*;
public class Dian {
static int h=1; static int g=1;static int f=0; static int fenshu=0; int m1=0;int n=0; static int e=0;static int d=0;//d表示完家点数总和
static String pai[]={"红桃","黑桃","红心","草花"};
static int shu[]={1,2,3,4,5,6,7,8,9,10,11,12,13};
public static int quzhi()
{
int m1 = (int) (13*Math.random()+1);
return m1;
}
public static int quzhi2()
{
int n = (int) (4*Math.random()+1);
return n;
}
public static void choupai()//玩家抽牌
{
int m=shu[quzhi()];
System.out.println(pai[quzhi2()]+m);
if(m>10) m=1;
System.out.println("点数"+m);
d=m+d;
System.out.println("玩家总点"+d);
if(d>21) {System.out.println("你输了");g=0;}
}
public static void choupai1()//庄家抽牌
{
int m=shu[quzhi()];
System.out.println(pai[quzhi2()]+m);
if(m>10) m=1;
System.out.println("点数"+m);
e=m+e;
System.out.println("庄家总点数"+e);
if(d>21) {System.out.println("你赢了");f=1;h=0;}
}
public static void main(String[] args) throws IOException {
choupai();
choupai1();
choupai();
choupai1();
Scanner in = new Scanner(System.in);
System.out.println("玩家再来一张牌请按1");
int b=in.nextInt(); //接收整形数据
if(b==1){choupai();}
if(g==1){
Scanner in2 = new Scanner(System.in);
System.out.println("庄家再来一张牌请按1");
int b1=in2.nextInt(); //接收整形数据
if(b1==1) {choupai1();}else h=0;}
if(g==1){
Scanner in1 = new Scanner(System.in);
System.out.println("玩家再来一张牌请按2");
int c=in1.nextInt(); //接收整形数据
if(c==2) choupai();
else if(d>e&&d<21){ System.out.println("玩家赢了");f=1;}
else System.out.println("你输了");}
if(h==1&&g==1){
Scanner in3 = new Scanner(System.in);
System.out.println("庄家再来一张牌请按2");
int c1=in3.nextInt(); //接收整形数据
if(c1==2) choupai1();
if(e>d) {System.out.println("你输了");}
else {System.out.println("你羸了");f=1;}}
if(f==1) fenshu=fenshu+5;
System.out.println("你的分数是"+fenshu);
f=0;g=1;
}
}
2人简单版没大小王。坐等高手解答
你这个50分可没人帮你写...