[HDU] [2017] String Statistics

Problem Description

Loading...

Problem Analysis

Turns out I can only post 20 blogs a day…
How am I supposed to fill this pit…
And yesterday’s saved blog got lost too…
So frustrating…
What was I saying yesterday…
I think it was…

I’ve seen this problem n times already!

cpp
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#include<stdio.h>
int main() {
    int i,j,n;
    char ch;
    scanf("%d\n",&j);
    for(i=0; i<j; i++) {
        n=0;
        while((ch=getchar())!='\n')

        {
            if(ch>='0'&&ch<='9')
                n++;

        }
        printf("%d\n",n);
    }
    return 0;
}

Loading...