C#实现简单车票管理系统适用于初学者
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _车票系统
{
class Program
{
static void Main(string[] args)
{
Console.Title = "简单车票系统";
string[,] zuo = new string[9, 4];
for (int i = 0; i < 9; i++) {
for (int j = 0; j < 4; j++) {
zuo[i, j] = "【有票】";
}
}
string s = string.Empty;
while (true) {
System.Console.Clear();
Console.WriteLine("\n 简单客车售票系统 " + "\n");
for (int i = 0; i < 9; i++) {
for (int j = 0; j < 4; j++) {
System.Console.Write(zuo[i, j]);
}
System.Console.WriteLine();
}
System.Console.Write("请输入座位行号和列号(如:0,2)输入q退出:");
s = System.Console.ReadLine();
if (s == "q") break;
string[] ss = s.Split( ',');
int one = int.Parse(ss[0]);
int two = int.Parse(ss[1]);
one -= 1;
two -= 1;
if (one <= 9 && two <= 4)
{
if (zuo[one, two] != "【已售】")
{
zuo[one, two] = "【已售】";
System.Console.Write("购票成功,按回车键继续购票!");
s = System.Console.ReadLine();
}
else {
System.Console.Write("购票失败,请按回车返回重新购票!");
s = System.Console.ReadLine();
}
}
else {
System.Console.Write("购票失败,请按回车返回重新购票!");
s = System.Console.ReadLine();
}
}
}
}
}