标签:
算法源自网络(网络源码连接:http://www.mycodes.net/161/6659.htm)
整体思路:用二维数组构建棋盘每一个数组元素封装为一个picturebox附带若干属性(例如:棋子归属方、棋子的类型),用一个抽象基类规定基本的棋子移动规则(例如:不能选中空白picturebox、该红方走棋时不能选中蓝方棋子),具体的棋子单独从基类棋子类派生 重写派生类的方法规定其走棋规则,和相应填充picturebox的图片(例如: 炮不能斜着走不能直线吃子,翻山炮必须吃子且移动路径上只能有一个棋子)
窗体所用控件:lable、timer、picturebox
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Windows.Forms; 6 using System.Drawing; 7 8 namespace 象棋_封_ 9 { 10 enum chess_type 11 { 12 blank, 13 jiang, 14 che, 15 ma, 16 pao, 17 xiang, 18 zu, 19 shi 20 };//棋类的枚举类型 21 enum player_type 22 { 23 blank, 24 red, 25 blue, 26 };//玩家类别的枚举类型 27 abstract class Chess 28 { 29 private static Chess[] cover_blue =new Chess[16];//被吃区 30 private static int r=0; 31 private static Chess[] cover_red = new Chess[16];//被吃区 32 private static int f=0; 33 protected static int chosenX; 34 protected static int chosenY; 35 public static bool chosen; 36 static int n = 1; 37 public static player_type control_side; 38 public PictureBox PB; 39 public chess_type type; 40 public player_type side; 41 public Chess() 42 { 43 side = player_type.blank; 44 type = chess_type.blank; 45 } 46 public abstract bool Move_judge(object sender, int X, int Y, Chess[][] checkerboard); 47 public abstract void Put_picture(); 48 //public void Assignment(chess_type ct, player_type pt, Image pic) 49 //{ 50 // side = pt; 51 // type = ct; 52 // PB.Image = pic; 53 //}//给棋子赋值 54 public void Bg_Tored() 55 { 56 this.PB.BackColor = Color.Red; 57 }//背景变为红色 58 public void Bg_Toblank() 59 { 60 this.PB.BackColor = Color.Transparent; 61 }//背景变为白色 62 private void Chess_Toblank(ref Chess a, PictureBox PB) 63 { 64 this.Bg_Toblank(); 65 this.PB.Image = null; 66 a = new Chess_blank(PB); 67 }//棋子属性清空 68 public static void Clearground(Main f, ref Chess[][] checkerboard)//布置战场 69 { 70 int i, j; 71 Control[] col_blue=null; 72 Control[] col_red=null; 73 Chess.control_side = player_type.red; 74 Chess.chosen = false; 75 //*********************初始化被吃区**************// 76 for (i = 0; i < 16; i++) 77 { 78 cover_blue[i] = new Chess_blank(); 79 cover_red[i] = new Chess_blank(); 80 } 81 for (i = 1; i <= 16; i++) 82 { 83 col_blue = f.Controls.Find("Cover_PBox_blue" + i, false);//检索控件 84 col_red = f.Controls.Find("Cover_PBox_red" + i, false);//检索控件 85 cover_blue[i - 1].PB = col_blue[0] as PictureBox; 86 cover_red[i - 1].PB = col_red[0] as PictureBox; 87 } 88 //*********************初始话被吃区**************// 89 90 //*****************构建棋盘********************// 91 checkerboard = new Chess[10][]; 92 for (i = 0; i < 10; i++) 93 { 94 checkerboard[i] = new Chess[9];//10行9列 95 } 96 for (i = 0; i < 10; i++) 97 for (j = 0; j < 9; j++) 98 { 99 checkerboard[i][j] = new Chess_blank(); 100 } 101 checkerboard[0][0] = new Chess_che(player_type.blue); 102 checkerboard[0][1] = new Chess_ma(player_type.blue); 103 checkerboard[0][2] = new Chess_xiang(player_type.blue); 104 checkerboard[0][3] = new Chess_shi(player_type.blue); 105 checkerboard[0][4] = new Chess_jiang(player_type.blue); 106 checkerboard[0][5] = new Chess_shi(player_type.blue); 107 checkerboard[0][6] = new Chess_xiang(player_type.blue); 108 checkerboard[0][7] = new Chess_ma(player_type.blue); 109 checkerboard[0][8] = new Chess_che(player_type.blue); 110 checkerboard[2][1] = new Chess_pao(player_type.blue); 111 checkerboard[2][7] = new Chess_pao(player_type.blue); 112 checkerboard[3][0] = new Chess_zu(player_type.blue); 113 checkerboard[3][2] = new Chess_zu(player_type.blue); 114 checkerboard[3][4] = new Chess_zu(player_type.blue); 115 checkerboard[3][6] = new Chess_zu(player_type.blue); 116 checkerboard[3][8] = new Chess_zu(player_type.blue); 117 118 119 checkerboard[6][0] = new Chess_zu(player_type.red); 120 checkerboard[6][2] = new Chess_zu(player_type.red); 121 checkerboard[6][4] = new Chess_zu(player_type.red); 122 checkerboard[6][6] = new Chess_zu(player_type.red); 123 checkerboard[6][8] = new Chess_zu(player_type.red); 124 checkerboard[7][1] = new Chess_pao(player_type.red); 125 checkerboard[7][7] = new Chess_pao(player_type.red); 126 checkerboard[9][0] = new Chess_che(player_type.red); 127 checkerboard[9][1] = new Chess_ma(player_type.red); 128 checkerboard[9][2] = new Chess_xiang(player_type.red); 129 checkerboard[9][3] = new Chess_shi(player_type.red); 130 checkerboard[9][4] = new Chess_jiang(player_type.red); 131 checkerboard[9][5] = new Chess_shi(player_type.red); 132 checkerboard[9][6] = new Chess_xiang(player_type.red); 133 checkerboard[9][7] = new Chess_ma(player_type.red); 134 checkerboard[9][8] = new Chess_che(player_type.red); 135 for (i = 0; i < 10; i++) 136 for (j = 0; j < 9; j++)//control 是一个存放控件类的容器 137 { 138 Control[] col = f.Controls.Find("pictureBox" + (i * 9 + j + 1), false);//检索控件 139 checkerboard[i][j].PB = col[0] as PictureBox;//类型转换 140 checkerboard[i][j].PB.Location = new Point(170 + 60 * j, 57 * i); 141 } 142 for (i = 0; i < 10; i++) 143 for (j = 0; j < 9; j++) 144 { 145 checkerboard[i][j].Put_picture(); 146 } 147 //*****************构建棋盘********************// 148 } 149 protected static int Getx(object sender) 150 { 151 int x; 152 string name = (sender as PictureBox).Name; 153 string number = name.Substring(10);//在字符串中从指定位开始检索(这里是在x后也就是picturebox控件ID不同的尾号) 154 int index = Convert.ToInt32(number); 155 x = (index - 1) / 9;//列 156 return x; 157 } 158 protected static int Gety(object sender) 159 { 160 int y; 161 string name = (sender as PictureBox).Name; 162 string number = name.Substring(10);//在字符串中从指定位开始检索(这里是在x后也就是picturebox控件ID不同的尾号) 163 int index = Convert.ToInt32(number); 164 y = (index - 1) % 9;//行 165 return y; 166 } 167 public static void Nochozen_dispose(object sender, Chess[][] checkerboard) 168 { 169 Chess.chosen = true; 170 chosenX = Chess.Getx(sender); 171 chosenY = Chess.Gety(sender); 172 if (checkerboard[chosenX][chosenY].side != control_side)//选择的不是当前应该走棋的一方 173 { 174 chosen = false; 175 return; 176 } 177 if (checkerboard[chosenX][chosenY].side != player_type.blank)//选择的不是空白 178 checkerboard[chosenX][chosenY].Bg_Tored(); 179 return; 180 } 181 public static bool Chozen_dispose(object sender, Chess[][] checkerboard) 182 { 183 Chess.chosen = false; 184 int x= Getx(sender); 185 int y= Gety(sender); 186 if (checkerboard[chosenX][chosenY].side == checkerboard[x][y].side)//移动位置与选择位是同一阵营 187 { 188 checkerboard[chosenX][chosenY].Bg_Toblank(); 189 return false; 190 } 191 if (checkerboard[chosenX][chosenY].side == player_type.blank)//选中的是空白 192 return false; 193 if (checkerboard[chosenX][chosenY].type == chess_type.ma || checkerboard[chosenX][chosenY].type == chess_type.xiang || checkerboard[chosenX][chosenY].type == chess_type.shi)//马象士的移动不能同y或同x 194 { 195 if (chosenX == x || chosenY == y) 196 { 197 checkerboard[chosenX][chosenY].Bg_Toblank(); 198 return false; 199 } 200 } 201 else 202 { 203 if (chosenX != x && chosenY != y)//其他棋类都必须同x或同y移动 204 { 205 checkerboard[chosenX][chosenY].Bg_Toblank(); 206 return false; 207 } 208 } 209 210 if (!checkerboard[chosenX][chosenY].Move_judge(sender, x, y, checkerboard)) 211 { 212 checkerboard[chosenX][chosenY].Bg_Toblank(); 213 return false; 214 } 215 if (Chess.Setmove(checkerboard, x, y)) 216 return true; 217 else 218 return false; 219 } 220 static bool Setmove(Chess[][] checkerboard,int X,int Y) 221 { 222 n++; 223 bool over = false; 224 player_type z=player_type.blank; 225 if (checkerboard[X][Y].type == chess_type.jiang) 226 { 227 over = true; 228 z = checkerboard[X][Y].side; 229 } 230 if (checkerboard[X][Y].PB.Image!=null) 231 Cover(checkerboard[X][Y]); 232 Chess.Change(ref checkerboard[Chess.chosenX][Chess.chosenY],ref checkerboard[X][Y]); 233 Chess.chosen = false; 234 if (over) 235 { 236 if (z == player_type.blue) 237 MessageBox.Show("红方胜利"); 238 else 239 MessageBox.Show("蓝方胜利"); 240 End f = new End(Time.fen + "分" + Time.miao + "秒"); 241 f.Show(); 242 return true; 243 } 244 if (n % 2 == 0) 245 Chess.control_side = player_type.blue; 246 else 247 Chess.control_side = player_type.red; 248 return false; 249 } 250 private static void Change(ref Chess a,ref Chess b)//a子位移到b子 251 { 252 Chess c = new Chess_blank(); 253 c.PB = b.PB; 254 switch (a.type) 255 { 256 case chess_type.zu: 257 b = new Chess_zu(a.side);break; 258 case chess_type.pao: 259 b = new Chess_pao(a.side);break; 260 case chess_type.che: 261 b = new Chess_che(a.side); break; 262 case chess_type.ma: 263 b = new Chess_ma(a.side); break; 264 case chess_type.xiang: 265 b = new Chess_xiang(a.side); break; 266 case chess_type.shi: 267 b = new Chess_shi(a.side); break; 268 case chess_type.jiang: 269 b = new Chess_jiang(a.side); break; 270 } 271 b.type = a.type; 272 b.side = a.side; 273 b.PB = c.PB; 274 b.PB.Image = a.PB.Image; 275 a.Chess_Toblank(ref a,a.PB); 276 } 277 private static void Cover(Chess a) 278 { 279 if (a.side == player_type.blue) 280 { 281 Change(ref a, ref cover_red[r]); 282 r++; 283 } 284 else 285 { 286 Change(ref a, ref cover_blue[f]); 287 f++; 288 } 289 290 }//棋子被吃后移动到被吃区 291 292 } 293 }
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Windows.Forms; 6 7 namespace 象棋_封_ 8 { 9 class Chess_blank : Chess 10 { 11 public Chess_blank() 12 { 13 base.type = chess_type.blank; 14 base.side = player_type.blank; 15 } 16 public Chess_blank(PictureBox PB) 17 { 18 base.type = chess_type.blank; 19 base.side = player_type.blank; 20 this.PB = PB; 21 } 22 public override bool Move_judge(object sender, int X, int Y, Chess[][] checkerboard) 23 { 24 return false; 25 } 26 public override void Put_picture() 27 { 28 this.PB.Image = null; 29 } 30 } 31 }
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 6 namespace 象棋_封_ 7 { 8 class Chess_che:Chess 9 { 10 public Chess_che(player_type b) 11 { 12 base.type = chess_type.che; 13 base.side = b; 14 } 15 public override bool Move_judge(object sender, int X, int Y, Chess[][] checkerboard) 16 { 17 int i, j, k; 18 if (Chess.chosenX == X) 19 { 20 i = Chess.chosenY < Y ? Chess.chosenY : Y; 21 j = Chess.chosenY > Y ? Chess.chosenY : Y; 22 for (k = i + 1; k < j; k++) 23 { 24 if (checkerboard[X][k].side != player_type.blank)//在移动路径上有棋子情况 25 { 26 return false; 27 } 28 } 29 } 30 if (Chess.chosenY == Y) 31 { 32 i = Chess.chosenX < X ? Chess.chosenX : X; 33 j = Chess.chosenX > X ? Chess.chosenX : X; 34 for (k = i + 1; k < j; k++) 35 { 36 if (checkerboard[k][Y].side != player_type.blank) 37 { 38 return false; 39 } 40 } 41 } 42 return true; 43 } 44 public override void Put_picture() 45 { 46 if (base.side == player_type.red) 47 this.PB.Image = global::象棋_封_.Properties.Resources.红車; 48 else 49 this.PB.Image = global::象棋_封_.Properties.Resources.蓝車; 50 } 51 } 52 }
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 6 namespace 象棋_封_ 7 { 8 class Chess_jiang:Chess 9 { 10 public Chess_jiang(player_type b) 11 { 12 base.type = chess_type.jiang; 13 base.side = b; 14 } 15 public override bool Move_judge(object sender, int X, int Y, Chess[][] checkerboard) 16 { 17 int i, j, k; 18 if (checkerboard[X][Y].type == chess_type.jiang && Chess.chosenY == Y)//王吃王情况 19 { 20 i = Chess.chosenX < X ? Chess.chosenX : X;//棋子移动的起点行 21 j = Chess.chosenX > X ? Chess.chosenX : X;//棋子移动的结束行 22 for (k = i + 1; k < j; k++) 23 { 24 if (checkerboard[k][Y].side != player_type.blank)//中间有棋子情况 25 { 26 return false; 27 } 28 } 29 return true; 30 } 31 if (this.side == player_type.blue) 32 { 33 34 if (Y < 3 || Y > 5 || X > 2)//当控制者是蓝色方 限制将的移动范围 35 { 36 return false; 37 } 38 } 39 else 40 { 41 if (Y < 3 || Y > 5 || X < 7)//当控制者是红色方 限制将的移动范围 42 { 43 return false; 44 } 45 } 46 if ((Chess.chosenX - X) * (Chess.chosenX - X) + (Chess.chosenY - Y) * (Chess.chosenY - Y) != 1)//点到点距离x平方加y平方 47 { 48 return false; 49 } 50 return true; 51 } 52 public override void Put_picture() 53 { 54 if (base.side == player_type.red) 55 this.PB.Image = global::象棋_封_.Properties.Resources.红帥; 56 else 57 this.PB.Image = global::象棋_封_.Properties.Resources.蓝将; 58 } 59 } 60 }
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 6 namespace 象棋_封_ 7 { 8 class Chess_ma:Chess 9 { 10 public Chess_ma(player_type b) 11 { 12 base.type = chess_type.ma; 13 base.side = b; 14 } 15 public override bool Move_judge(object sender, int X, int Y, Chess[][] checkerboard) 16 { 17 if (Math.Abs(Chess.chosenX - X) == 1 && Math.Abs(Chess.chosenY - Y) == 2)//移动X方向绝对值为1y方向为2 18 { 19 if (checkerboard[Chess.chosenX][Chess.chosenY + (Y - Chess.chosenY) / Math.Abs(Y - Chess.chosenY)].side != player_type.blank)//不是撇脚马 20 { 21 return false; 22 } 23 } 24 else if (Math.Abs(Chess.chosenX - X) == 2 && Math.Abs(Chess.chosenY - Y) == 1)//移动y方向绝对值为2x方向为1 25 { 26 if (checkerboard[Chess.chosenX + (X - Chess.chosenX) / Math.Abs(X - Chess.chosenX)][Chess.chosenY].side != player_type.blank)//不是撇脚马 27 { 28 return false; 29 } 30 } 31 else 32 { 33 return false; 34 } 35 return true; 36 } 37 public override void Put_picture() 38 { 39 if (base.side == player_type.red) 40 this.PB.Image = global::象棋_封_.Properties.Resources.红马; 41 else 42 this.PB.Image = global::象棋_封_.Properties.Resources.蓝马; 43 } 44 } 45 }
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 6 namespace 象棋_封_ 7 { 8 class Chess_pao:Chess 9 { 10 public Chess_pao(player_type b) 11 { 12 base.type = chess_type.pao; 13 base.side = b; 14 } 15 public override bool Move_judge(object sender, int X, int Y, Chess[][] checkerboard) 16 { 17 int p = 0;//用于记录路径上的棋子数 18 int i, j, k; 19 if (Chess.chosenX == X)//同列移动情况 20 { 21 i = Chess.chosenY < Y ? Chess.chosenY : Y;//定起始点 22 j = Chess.chosenY > Y ? Chess.chosenY : Y;//定起始点 23 p = 0; 24 for (k = i + 1; k < j; k++) 25 { 26 if (checkerboard[X][k].side != player_type.blank) 27 { 28 p++;//移动路径上有棋子的个数 29 } 30 } 31 if (p > 1) 32 { 33 return false; 34 } 35 } 36 37 38 else if (Chess.chosenY == Y)//同行移动情况 39 { 40 i = Chess.chosenX < X ? Chess.chosenX : X; 41 j = Chess.chosenX > X ? Chess.chosenX : X; 42 p = 0; 43 for (k = i + 1; k < j; k++) 44 { 45 if (checkerboard[k][Y].side != player_type.blank) 46 { 47 p++; 48 } 49 } 50 if (p > 1) 51 { 52 return false; 53 } 54 } 55 else 56 { 57 return false; 58 } 59 if (p == 0 && checkerboard[X][Y].side != player_type.blank)//中间没有棋子炮不能吃子 60 { 61 return false; 62 } 63 if (p == 1 && checkerboard[X][Y].side == player_type.blank)//中间有棋子但是不能打空炮 64 { 65 return false; 66 } 67 return true; 68 } 69 public override void Put_picture() 70 { 71 if (base.side == player_type.red) 72 this.PB.Image = global::象棋_封_.Properties.Resources.红炮; 73 else 74 this.PB.Image = global::象棋_封_.Properties.Resources.蓝炮; 75 } 76 } 77 }
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 6 namespace 象棋_封_ 7 { 8 class Chess_shi:Chess 9 { 10 public Chess_shi(player_type b) 11 { 12 base.type = chess_type.shi; 13 base.side = b; 14 } 15 public override bool Move_judge(object sender, int X, int Y, Chess[][] checkerboard) 16 { 17 if (this.side == player_type.blue) 18 { 19 if (Y < 3 || Y > 5 || X > 2)//限制将的移动范围 20 { 21 return false; 22 } 23 } 24 else 25 { 26 if (Y < 3 || Y > 5 || X < 7)//限制将的移动范围 27 { 28 return false; 29 } 30 } 31 if (Math.Abs(X - Chess.chosenX) != 1 || Math.Abs(Chess.chosenY - Y) != 1)//只能跨一个方格 32 { 33 return false; 34 } 35 return true; 36 } 37 public override void Put_picture() 38 { 39 if (base.side == player_type.red) 40 this.PB.Image = global::象棋_封_.Properties.Resources.红士; 41 else 42 this.PB.Image = global::象棋_封_.Properties.Resources.蓝士; 43 } 44 } 45 }
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 6 namespace 象棋_封_ 7 { 8 class Chess_xiang:Chess 9 { 10 public Chess_xiang(player_type b) 11 { 12 base.type = chess_type.xiang; 13 base.side = b; 14 } 15 public override bool Move_judge(object sender, int X, int Y, Chess[][] checkerboard) 16 { 17 if (this.side == player_type.blue) 18 { 19 if (X > 4) 20 { 21 return false; 22 } 23 } 24 else 25 { 26 if (X < 5) 27 { 28 return false; 29 } 30 } 31 if ((X - Chess.chosenX) * (X - Chess.chosenX) + (Chess.chosenY - Y) * (Chess.chosenY - Y) != 8) 32 { 33 return false; 34 } 35 if (checkerboard[(X + Chess.chosenX) / 2][(Y + Chess.chosenY) / 2].side != player_type.blank) 36 { 37 return false; 38 } 39 return true; 40 } 41 public override void Put_picture() 42 { 43 if (base.side == player_type.red) 44 this.PB.Image = global::象棋_封_.Properties.Resources.红象; 45 else 46 this.PB.Image = global::象棋_封_.Properties.Resources.蓝象; 47 } 48 } 49 }
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 6 namespace 象棋_封_ 7 { 8 class Chess_zu:Chess 9 { 10 public Chess_zu(player_type b) 11 { 12 base.type = chess_type.zu; 13 base.side = b; 14 } 15 public override bool Move_judge(object sender, int X, int Y, Chess[][] checkerboard) 16 { 17 if (this.side == player_type.blue)//蓝方卒 18 { 19 if (Chess.chosenX < 5 && X - Chess.chosenX != 1)//在5行后选中的卒 20 { 21 return false; 22 } 23 if (Chess.chosenX > 4)//移动布数不能大于1 24 { 25 if (X == Chess.chosenX && Math.Abs(Y - Chess.chosenY) != 1) 26 { 27 return false; 28 } 29 if (Y == Chess.chosenY && X - Chess.chosenX != 1) 30 { 31 return false; 32 } 33 } 34 } 35 else//红方卒 36 { 37 if (Chess.chosenX > 4 && Chess.chosenX - X != 1) 38 { 39 return false; 40 } 41 if (Chess.chosenX < 5) 42 { 43 if (X == Chess.chosenX && Math.Abs(Y - Chess.chosenY) != 1) 44 { 45 return false; 46 } 47 if (Y == Chess.chosenY && Chess.chosenX - X != 1) 48 { 49 return false; 50 } 51 } 52 } 53 return true; 54 } 55 public override void Put_picture() 56 { 57 if (base.side == player_type.red) 58 this.PB.Image = global::象棋_封_.Properties.Resources.红兵; 59 else 60 this.PB.Image = global::象棋_封_.Properties.Resources.蓝卒; 61 } 62 } 63 }
1 using System; 2 using System.Collections.Generic; 3 using System.ComponentModel; 4 using System.Data; 5 using System.Drawing; 6 using System.Linq; 7 using System.Text; 8 using System.Windows.Forms; 9 10 namespace 象棋_封_ 11 { 12 public partial class Start : Form 13 { 14 public Start() 15 { 16 InitializeComponent(); 17 } 18 19 private void LB_Begin_Click(object sender, EventArgs e) 20 { 21 Main f = new Main(); 22 f.Show(); 23 this.Hide(); 24 } 25 26 private void label2_Click(object sender, EventArgs e) 27 { 28 About f = new About(); 29 f.Show(); 30 this.Hide(); 31 } 32 33 private void LB_exit_Click(object sender, EventArgs e) 34 { 35 Application.Exit(); 36 } 37 } 38 }
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Windows.Forms; 6 7 namespace 象棋_封_ 8 { 9 class Time 10 { 11 public Timer t; 12 private Label l; 13 private double s ; 14 private double m ; 15 public double sum=0; 16 public static string fen="0"; 17 public static string miao ="0"; 18 public Time(Timer t,Label L) 19 { 20 s = 0; 21 m = 0; 22 this.t = t; 23 this.l = L; 24 } 25 public string outtime() 26 { 27 string second; 28 string minute; 29 s++; 30 if (s >= 60) 31 { 32 m = s / 60; 33 s = s % 60; 34 } 35 second = Convert.ToString(s); 36 minute = Convert.ToString(m); 37 string sum = minute + ":" + second; 38 return sum; 39 } 40 public void clear() 41 { 42 fen = (Convert.ToInt32(fen) + m).ToString(); 43 miao = (Convert.ToInt32(miao) + s).ToString(); 44 l.Text = ""; 45 m = 0; 46 s = 0; 47 } 48 } 49 }
标签:
原文地址:http://www.cnblogs.com/cyh1282656849/p/5741236.html