【发布时间】:2014-03-29 15:41:48
【问题描述】:
首先我想说我是 C 和编程的初学者。 C 是我的第一语言,我觉得它很有趣。 我正在编写一个模拟电影软件的程序。我的意思是你选择电影、时间和座位。 我已经完成了电影和时间的选择,但座位有问题。 我想做的是当你选择行和列时,以某种方式在控制台中打印出哪个座位被占用(改变颜色,增加字体或类似的东西)
这是我的代码:
void SeatSelection()
{
int row = 0;
int column = 0;
int i, j;
printf("\t\t\t\tSCREEN\n\n\n\n\n\n\n");
int A[11][11] = {
{ 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 },
{ 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 },
{ 3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 },
{ 4, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 },
{ 5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 },
{ 6, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 },
{ 7, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 },
{ 8, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 },
{ 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 },
{ 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }
};
for (i = 0; i < 10; i++)
{
for (j = 0; j < 11; j++)
printf("%d\t", A[i][j]);
printf("\n\n");
}
do
{
printf("Choose seat: Row and Column\n");
scanf("%d %d", &row, &column);
if ((row<1 || row>10) && (column<1 || column>10)) printf("Wrong choice, try again\n");
} while ((row<1 || row>10) && (column<1 || column>10));
}
提前感谢您的帮助:)
【问题讨论】: