日期:2014-05-18 浏览次数:20759 次
public void AutoTakeMoney() { int[,] sql = new int[3, 3] {{123,456,5000},{789,132,1800},{159,753,3000}}; Console.WriteLine("欢迎使用建设银行提款机"); start_1: Console.WriteLine("请输入您的账号"); int username = int.Parse(Console.ReadLine()); //验证账号 for (int i = 0; i < sql.GetLength(0); i++) { if (username == sql[i,0]) { Console.WriteLine("账号正确"); goto start2; //break; } else { if (i == sql.GetLength(0) - 1) { Console.WriteLine("账号错误"); goto start_1; } } } //验证密码 start2: Console.WriteLine("请输入您的密码"); int password = int.Parse(Console.ReadLine()); int count = 0; for (int i = 0; i < sql.GetLength(0); i++) { for (int k = 0; k < sql.GetLength(1); k++) { if (password == sql[i, k] && username == sql[i, 0]) { Console.WriteLine("密码正确"); goto start3; //return; } else { if (k == sql.GetLength(1)-1&&i==sql.GetLength(0)-1) { Console.WriteLine("密码错误"); count++; if (count > 3) { Console.WriteLine("密码输入错误超过3次,请取卡"); } //return; goto start2; } } } } start3: Console.WriteLine("请选择你要进行的操作:1.查询余额\t2.存款\t3.取款\t4.取卡"); int operate = int.Parse(Console.ReadLine()); switch (operate) { case 1: if (username == 123) { Console.WriteLine("还有{0}个大洋", sql[0, 2]); Console.WriteLine("还要继续吗?Y or N"); string choose = Console.ReadLine().ToUpper(); if (choose == "Y") { Console.Clear(); goto start3; } else { Console.WriteLine("不继续就取回卡片"); return; } } if (username == 789) { Console.WriteLine("还有{0}个大洋", sql[1, 2]); Console.WriteLine("还要继续吗?Y or N"); string choose = Console.ReadLine().ToUpper(); if (choose == "Y") { Console.Clear(); goto start3; } else { Console.WriteLine("不继续就取回卡片");