📄 ex05-08.cpp
字号:
//EX05-08.cpp
#include <iostream.h> //cout,cin
#include <conio.h> // getch()
const int SHOW=5;
const int ROW=15;
const int SEAT=20;
const int PRICE=180;
void main()
{ int theater[SHOW][ROW][SEAT],i,j,k,count,total=0;
char yn;
for (i=0;i<SHOW;i++) //Set 0
for (j=0;j<ROW;j++)
for (k=0;k<SEAT;k++)
theater[i][j][k]=0;
do
{ int show,row,seat;
cout <<"Enter Show(1-5),Row(1-15),Seat(1-20):";
cin >> show >> row >> seat;
show--;
row--;
seat--;
if (show>=0 && show<SHOW && row>=0 && row<ROW && seat>=0 && seat<SEAT)
theater[show][row][seat]=1;
cout << "Another person(y/n)?";
cin >> yn;
}while (yn=='y' || yn=='Y');
for (i=0;i<SHOW;i++)
{ cout << "第"<<(i+1)<<"场划位:\n";
count=0;
for (j=0;j<ROW;j++)
{
for (k=0;k<SEAT;k++)
{ cout <<theater[i][j][k]<<' ';
if (theater[i][j][k]==1) count++;
}
cout << endl;
}
cout << "Income =" <<count * PRICE;
total+=count*PRICE;
cout << "\nPress any key...";
getch();
}
cout << "\nTotal Income="<<total;
getch();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -