1
0
mirror of https://github.com/renbaoshuo/202401-programming-assignments.git synced 2024-11-27 08:26:20 +00:00
202401-programming-assignments/【额外练习】循环结构/7-2 循环-找数字.c

22 lines
300 B
C
Raw Permalink Normal View History

2024-11-18 15:10:07 +00:00
#include <stdio.h>
#include <string.h>
int main() {
char str[100];
int count = 0;
gets(str);
int len = strlen(str);
for (int i = 0; i < len; i++) {
if (str[i] >= '0' && str[i] <= '9') {
count++;
}
}
printf("%d\n", count);
return 0;
}