C_Sharp 板


LINE

小妹是刚学两个礼拜的C#新手 经理给了一个作业 说要做简易的大老二 我目前只写到发牌 可是发出来的排有点怪异 希望各位版友可以不吝指教 namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } //定义52张扑克牌 int[] poker = new int[53]; // poker[0]是临时变量(交换的手)所以要设到53 private void btnStart_Click(object sender, EventArgs e) { for (int i = 1; i <= 52; i++) // poker[0]是临时变量所以不写进去 poker[i] = i; //一开始编号第n张牌就是对应照顺序的第n张牌 Random rnd = new Random((int)DateTime.Now.Ticks); int j = 0; for (int i = 1; i < 53; i++) //用交换的概念来洗牌(三个交换) { j = rnd.Next(1, 53); poker[0] = poker[53 - i]; poker[53 - i] = poker[j]; poker[j] = poker[0]; } int[,] player = new int[4, 13]; //有四个玩家,各有十三张牌(发十三 轮) for (int i = 0; i < 52; i++) { int x = i % 4; // 表示第几个玩家;取余 int y = i / 4; // 表示发第几张牌(轮);取商 player[x, y] = poker[i + 1]; //第x位玩家的第y张牌是poker[i+1] 对应的牌 int f = player[x, y] % 4;//判定花色 string F = ""; switch (f) { case 0: F = "C"; //梅花 break; case 1: F = "H"; //红心 break; case 2: F = "D"; //方块 break; case 3: F = "S"; //黑桃 break; } if (x == 0) { label1.Text = F + Convert.ToString(player[x, 0]); label2.Text = F + Convert.ToString(player[x, 1]); label3.Text = F + Convert.ToString(player[x, 2]); label4.Text = F + Convert.ToString(player[x, 3]); label5.Text = F + Convert.ToString(player[x, 4]); label6.Text = F + Convert.ToString(player[x, 5]); label7.Text = F + Convert.ToString(player[x, 6]); label8.Text = F + Convert.ToString(player[x, 7]); label9.Text = F + Convert.ToString(player[x, 8]); label10.Text = F + Convert.ToString(player[x, 9]); label11.Text = F + Convert.ToString(player[x, 10]); label12.Text = F + Convert.ToString(player[x, 11]); label13.Text = F + Convert.ToString(player[x, 12]); } 省略x==1至x==3 btnStart.Enabled = false; } 发出来的排变成这样 http://ppt.cc/OFv1 前面的英文字代表的是花色 可是我不懂为什麽这样子他们的花色通通变成一样的'~' 拜托各位版友指教 谢谢~~ --



※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 114.44.193.222
1F:推 qwer820404:我还在找为什麽 不过 我建议 你把扑克牌用class写 10/14 14:00
2F:→ qwer820404:宣告一个class 里面存 一张纸牌的资料(花色跟点数) 10/14 14:01
3F:→ qwer820404:再利用这class 宣告出一个52大小的阵列 後面好做很多 10/14 14:03
4F:→ qwer820404:如果有不懂的问题 站内信吧 10/14 14:03
5F:→ sholan:改label写在for里,每发一张牌就会以该张花色盖掉全部Label 10/14 16:41
6F:→ drizzt123:因为你在回圈内填LABEL,所以F会是回圈内最後一个 10/14 23:17







like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草

请输入看板名称,例如:e-shopping站内搜寻

TOP