zzuli OJ 1065: 统计数字字符的个数1

来源:互联网 发布:阿里云香港b区 编辑:程序博客网 时间:2024/04/19 21:58

Description

输入一行字符,以回车符作为输入结束的标志。统计其中数字字符的个数。

Input

多个字符,以回车符结束,回车符不作为有效字符。

Output

输出一个整数,表示数字字符的个数。

Sample Input

12abrt12@2013

Sample Output

8

HINT

Source


#include<stdio.h>#include<ctype.h>int main(){    char ch;    int count = 0;    while( ch = getchar(), ch != '\n') //若读入的字符不是回车    {        if(isdigit(ch)) //若是数字            count++;    }    printf("%d\n", count);    return 0;}


0 0
原创粉丝点击