RVBTCC/test/loop/parse.c

19 lines
291 B
C
Raw Normal View History

2024-11-28 14:50:12 +00:00
int getchar();
int is_digit(int ch) {
return '0' <= ch && ch <= '9';
}
int parse_int(int ch) {
int num = ch - '0';
while (is_digit(ch = getchar())) {
num = num * 10;
num = num + ch - '0';
}
return num;
}
int main() {
return parse_int(getchar());
}