... | ... | @@ -19,3 +19,52 @@ A continuación se detalla la guía de estilo simple que utilizaremos en todas l |
|
|
- Evita duplicación de código
|
|
|
|
|
|
Ejempo:
|
|
|
|
|
|
```c
|
|
|
/*
|
|
|
Ejemplo código C
|
|
|
Sistemas Distribuidos y Concurrentes
|
|
|
*/
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
#define MAX_ERROR 100
|
|
|
|
|
|
int main() {
|
|
|
int temperature = 0, error;
|
|
|
char sensor_state;
|
|
|
|
|
|
printf("Enter State of Sensor (A/D): ");
|
|
|
scanf("%c", &sensors_state);
|
|
|
|
|
|
printf("Enter temperature: ");
|
|
|
scanf("%d", &temperature);
|
|
|
|
|
|
printf("Enter error (+- 1 degree): ");
|
|
|
scanf("%d", &error);
|
|
|
|
|
|
if (sensor_state == 'A') {
|
|
|
printf("Sensor enable\n");
|
|
|
} else {
|
|
|
printf("Sensor disable\n");
|
|
|
}
|
|
|
|
|
|
do {
|
|
|
if (temperature % 2 == 0) {
|
|
|
printf("Even temperature %d\n", temperature);
|
|
|
}
|
|
|
temperature--;
|
|
|
} while (temperature >= 0);
|
|
|
|
|
|
|
|
|
if (error > 0 && error <= 15) {
|
|
|
printf("Type1\n");
|
|
|
} else if (error > 15 && error <= 30) {
|
|
|
printf("Type2\n");
|
|
|
} else {
|
|
|
printf("Other type\n");
|
|
|
}
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
``` |