File tree Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Original file line number Diff line number Diff line change 7
7
#include <stdlib.h>
8
8
#include <string.h>
9
9
10
+ #define VAL (key ) (key[0])
11
+ #define VAL2 (val ) (val * 2)
12
+
10
13
/*
11
14
* Realiza una serie de operaciones leídas por entrada estándar.
12
15
*/
@@ -19,7 +22,7 @@ int main(void) {
19
22
while (getline (& linea , & tam , stdin ) >= 0 ) {
20
23
const char * key = linea + 1 ;
21
24
void * val ;
22
- intptr_t ival = * key ;
25
+ intptr_t ival = VAL ( key ) ;
23
26
24
27
switch (* linea ) {
25
28
case 'G' :
@@ -35,7 +38,7 @@ int main(void) {
35
38
36
39
case 'R' :
37
40
// Reemplazar
38
- printf ("OK %d\n" , abb_guardar (abb , key , (void * ) (ival * 2 )));
41
+ printf ("OK %d\n" , abb_guardar (abb , key , (void * ) VAL2 (ival )));
39
42
break ;
40
43
41
44
case 'O' :
Original file line number Diff line number Diff line change @@ -220,12 +220,19 @@ def setUp(self):
220
220
stderr = subprocess .PIPE )
221
221
222
222
223
- def val (x ):
224
- return x + ord ("0" )
223
+ def val (key ):
224
+ """Valor guardado en el ABB: código ASCII del primer caracter.
225
+
226
+ Debe estar sincronizado con la implementación en C.
227
+ """
228
+ assert key < 10 # El código C no soporta double-digits.
229
+ return key + ord ("0" )
225
230
226
231
227
- def val2 (x ):
228
- return val (x ) * 2
232
+ def val2 (key ):
233
+ """Valor para los reemplazos del ABB: el doble del primer valor.
234
+ """
235
+ return val (key ) * 2
229
236
230
237
231
238
if __name__ == "__main__" :
You can’t perform that action at this time.
0 commit comments