#include <stdio.h>
#include <ctype.h>
int main()
{
char ch;
int i;
i=0;
while(ch=getchar(),ch!=’\n’)
{
if(isdigit(ch))//等价于ch>=‘0’ && ch<=‘9’;要注意使用isdigit时需要在头文件中出现<ctype.h>
{
i++;
}
}
printf("%d\n",i);
return 0;
}
#include <stdio.h>
#include <ctype.h>
int main()
{
char ch;
int i;
i=0;
while(ch=getchar(),ch!=’\n’)
{
if(isdigit(ch))//等价于ch>=‘0’ && ch<=‘9’;要注意使用isdigit时需要在头文件中出现<ctype.h>
{
i++;
}
}
printf("%d\n",i);
return 0;
}