标签:main har 技术 门禁 images ima 门禁系统 while 汽车
其状态机如下图:
#include<iostream>
using namespace std;
void main()
{
char enter_or_out; //1表示入闸传感器ture,0表示出闸传感器ture
int up_or_downt = 0; //1表示起落杆升起,0表示起落杆落下
cout << "状态初始化..." << ‘\n‘;
cout << "当前状态为起落杆落下,红灯状态,禁止通行" << ‘\n‘;
while (1)
{
cout << "检测是否有车进入或离开门禁系统y or n" << ‘\n‘;
cin >> enter_or_out;
if (enter_or_out == ‘y‘)
{
cout << "入闸传感器ture,有车驶入" << ‘\n‘;
up_or_downt = 1;
cout << "起落杆升起" <<‘\n‘;
cout << "通行灯为绿灯,汽车可通行" << ‘\n‘;
}
if (enter_or_out == ‘n‘)
{
cout << "出闸传感器ture,汽车驶出门禁系统" << ‘\n‘;
up_or_downt = 0;
cout << "起落杆落下" << ‘\n‘;
cout << "通行灯为红灯,汽车禁止通行" << ‘\n‘;
}
}
}
标签:main har 技术 门禁 images ima 门禁系统 while 汽车
原文地址:http://www.cnblogs.com/u201310615/p/6139354.html