From a8e49d4b25c75c4392e0ad6e38a543d403567d0a Mon Sep 17 00:00:00 2001 From: Sadeep Madurange Date: Tue, 23 Nov 2021 23:21:22 +0800 Subject: 1.24 --- 1/24.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to '1') diff --git a/1/24.c b/1/24.c index 0e8e53f..7091896 100644 --- a/1/24.c +++ b/1/24.c @@ -16,16 +16,15 @@ int main(int argc, char *argv[]) { parens = bracks = braces = 0; for (i = 0; i < MAXLEN - 1 && (c = getchar()) != EOF; i++) { - if (!comment && !quote && (c == '/' || c == '*') && p == '/') { - comment = c == '/' ? INLINE : MULTILINE; - } else if (!comment && !quote && c == '"') { - quote = TRUE; - } else if (comment == INLINE && c == '\n') { + if (!comment && !quote) { + if ((c == '/' || c == '*') && p == '/') + comment = c == '/' ? INLINE : MULTILINE; + else if (c == '"') + quote = TRUE; + } else if ((comment == INLINE && c == '\n') || + (comment == MULTILINE && c == '/' && p == '*')) { comment = FALSE; - } else if (comment == MULTILINE && c == '/' && p == '*') { - comment = FALSE; - } - if (!comment && quote && c == '"' && p != '\\') { + } else if (!comment && quote && c == '"' && p != '\\') { quote = FALSE; } else if (!comment && !quote) { if (c == '{') -- cgit v1.2.3