您的位置:首页 > 其它

随机抽取一张纸牌

2015-09-22 20:19 260 查看
import java.util.Scanner;

public class tt {

	public static void main(String[] args) {
		String a[] = { "Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10",
				"jack", "queen", "king" };
		int n1 = (int) (Math.random() * 13);
		System.out.print("The card is ");
		System.out.print(a[n1]);
		String b[] = { "Clubs", "Diamonds", "Hearts", "Spades" };
		int n2 = (int) (Math.random() * 4);
		System.out.print(" of " + b[n2]);
	}
}

结果:

The card is 8 of Clubs
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: