sensori.cpp

This commit is contained in:
Vichingo455 2024-10-18 11:19:51 +00:00
parent 074d33d3f5
commit 6d6b0da1d3
2 changed files with 71 additions and 0 deletions

BIN
cicli_operatori/sensori Executable file

Binary file not shown.

View File

@ -0,0 +1,71 @@
/*
AUTORE: Manuel Vichi 3^AIN
Sistema di allarme
*/
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main(void) {
int bit0 = 0, bit1 = 0, bit2 = 0, bit3 = 0, bit4 = 0, bit5 = 0, bit6 = 0, bit7 = 0;
// Imposta i sensori casualmente
srand(static_cast<unsigned int>(time(0)));
bit0 = std::rand() % 2;
bit1 = std::rand() % 2;
bit2 = std::rand() % 2;
bit3 = std::rand() % 2;
bit4 = std::rand() % 2;
bit5 = std::rand() % 2;
bit6 = std::rand() % 2;
bit7 = std::rand() % 2;
cout << "Stato sensori:" << endl;
if (bit0 == 1) {
cout << "Cucina: ALLARME ON" << endl;
}
else {
cout << "Cucina: ALLARME OFF" << endl;
}
if (bit1 == 1) {
cout << "Sala: ALLARME ON" << endl;
}
else {
cout << "Sala: ALLARME OFF" << endl;
}
if (bit2 == 1) {
cout << "Balcone: ALLARME ON" << endl;
}
else {
cout << "Balcone: ALLARME OFF" << endl;
}
if (bit3 == 1) {
cout << "Luci: ALLARME ON" << endl;
}
else {
cout << "Luci: ALLARME OFF" << endl;
}
if (bit4 == 1) {
cout << "Ingresso: ALLARME ON" << endl;
}
else {
cout << "Ingresso: ALLARME OFF" << endl;
}
if (bit5 == 1) {
cout << "Letto 1: ALLARME ON" << endl;
}
else {
cout << "Letto 1: ALLARME OFF" << endl;
}
if (bit6 == 1) {
cout << "Letto 2: ALLARME ON" << endl;
}
else {
cout << "Letto 2: ALLARME OFF" << endl;
}
if (bit7 == 1) {
cout << "Bagno: ALLARME ON" << endl;
}
else {
cout << "Bagno: ALLARME OFF" << endl;
}
return 0;
}