水晶592 2022-11-08 18:50 采纳率: 100%
浏览 9
已结题

汽车报警装置csapp实验

问题遇到的现象和发生背景

汽车报警装置csapp实验

用代码块功能插入代码,请勿粘贴截图

#include <stdio.h> //This is useful to do i/o to test the code
unsigned int driver_on_seat;//1//
unsigned int doors_closed;//4//
unsigned int bell;//1//
void read_inputs_from_ip_if(){
driver_on_seat=1;
doors_closed=1;
unsigned int driver_seat_belt_fastened=1;//2
unsigned int engine_running=1;//3
unsigned int key_in_car=1;//5
unsigned int door_lock_lever=1;//6
unsigned int brake_pedal=1;//7
unsigned int car_moving=1;//8
unsigned int door_lock;//2
unsigned int brake;//3
//place your input code here
//to read the current state of the available sensors
}
void write_output_to_op_if(){
printf("The state of the 3 actuators (DLA/BELL/BA) is: \n");
printf("%x, %x, %x.\n", door_lock, bell, brake);
//place your output code here
//to display/print the state of the 3 actuators (DLA/BELL/BA)
}
//The code segment which implements the decision logic
void control_action(){
if (driver_on_seat && !doors_closed)
bell = 1;
else if (!driver_seat_belt_fastened && engine_running)
bell = 1;
else bell = 0;
if (!driver_on_seat && key_in_car)
door_lock = 0;
else door_lock = 1;
if (brake_pedal && car_moving)
brake = 1;
else brake = 0;
}
int main(int argc, char *argv[])
{
for (; ; )
{
read_inputs_from_ip_if();
control_action();
write_output_to_op_if();
}
return 0;
}

运行结果及报错内容

img

我想要达到的结果

成功运行,找到错误原因

  • 写回答

0条回答 默认 最新

    报告相同问题?

    问题事件

    • 系统已结题 11月16日
    • 创建了问题 11月8日

    悬赏问题

    • ¥15 对接wps接口实现获取元数据
    • ¥20 给自己本科IT专业毕业的妹m找个实习工作
    • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
    • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
    • ¥50 mac mini外接显示器 画质字体模糊
    • ¥15 TLS1.2协议通信解密
    • ¥40 图书信息管理系统程序编写
    • ¥20 Qcustomplot缩小曲线形状问题
    • ¥15 企业资源规划ERP沙盘模拟
    • ¥15 树莓派控制机械臂传输命令报错,显示摄像头不存在