diff --git a/cicli_operatori/sensori b/cicli_operatori/sensori new file mode 100755 index 0000000..85a4882 Binary files /dev/null and b/cicli_operatori/sensori differ diff --git a/cicli_operatori/sensori.cpp b/cicli_operatori/sensori.cpp new file mode 100644 index 0000000..84ddc1d --- /dev/null +++ b/cicli_operatori/sensori.cpp @@ -0,0 +1,71 @@ +/* +AUTORE: Manuel Vichi 3^AIN +Sistema di allarme +*/ +#include +#include +#include +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(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; +}