diff options
Diffstat (limited to '2023/03/3b.c')
| -rw-r--r-- | 2023/03/3b.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/2023/03/3b.c b/2023/03/3b.c index 27b5b7c..9bf4c27 100644 --- a/2023/03/3b.c +++ b/2023/03/3b.c | |||
| @@ -1,22 +1,16 @@ | |||
| 1 | #include <stdbool.h> | ||
| 2 | #include <stdio.h> | 1 | #include <stdio.h> |
| 3 | #include <stdlib.h> | 2 | #include <stdlib.h> |
| 4 | #include <string.h> | 3 | #include <string.h> |
| 5 | 4 | ||
| 6 | #define N 1000 | 5 | #define N 1000 |
| 7 | 6 | #define ISNUM(c) (c >= '0' && c <= '9') | |
| 8 | bool isnum(char c) { return c >= '0' && c <= '9'; } | ||
| 9 | 7 | ||
| 10 | int grab(char *buf) { | 8 | int grab(char *buf) { |
| 11 | int x; | 9 | if (!ISNUM(*buf)) return 0; |
| 12 | 10 | while (ISNUM(*buf)) buf--; | |
| 13 | if (!isnum(*buf)) | ||
| 14 | return 0; | ||
| 15 | |||
| 16 | while (isnum(*buf)) buf--; | ||
| 17 | buf++; | 11 | buf++; |
| 18 | x = atoi(buf); | 12 | int x = atoi(buf); |
| 19 | while (isnum(*buf)) *buf++ = '.'; | 13 | while (ISNUM(*buf)) *buf++ = '.'; |
| 20 | 14 | ||
| 21 | return x; | 15 | return x; |
| 22 | } | 16 | } |
