HDU 2017 string statistics, hdu2017 string statistics
String statistics
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission (s): 40487 Accepted Submission (s): 22532
Problem Description calculates the number of occurrences of numeric characters in a given string.
The Input data has multiple rows. The first row is an integer n, indicating the number of test instances, followed by n rows. Each row contains a string consisting of letters and numbers.
Output: For each test instance, the number of values in the string is Output, and each Output occupies one row.
Sample Input
2asdfasdf123123asdfasdfasdf111111111asdfasdfasdf
Sample Output
69
# Include <stdio. h> char a [1000]; int main () {int n; scanf ("% d", & n); getchar (); // note that while (n --) {int I, t = 0; gets (a); for (I = 0; a [I]! = '\ 0'; I ++) {if (a [I]> = '0' & a [I] <'9') t ++ ;} printf ("% d \ n", t);} return 0 ;}
Hangdian acm2017
If you are interested in practicing ACM, the program will lose its meaning here. What should LZ do?
Main Code:
Int t, cnt, c;
Scanf ("% d", & t); // The space after % d is used to match the line break of the first line.
While (t --){
Cnt = 0;
While ('\ n '! = (C = getchar ()){
If ('0' <= c & c <= '9') cnt ++;
}
Printf ("% d \ n", cnt );
}
2017 of hangdian acm (C language)
# Include <stdio. h>
# Include <string. h>
Int main (void)
{
Int n, I, j, num;
Char s [1000];
Char * p;
Scanf ("% d", & n );
For (I = 1; I <= n + 1; I ++)
{
Num = 0;
J = 0;
Gets (s );
For (p = s; * p! = '\ 0'; p ++)
{
If (* p> = '0' & * p <= '9 ')
{
Num ++;
}
}
If (I! = 1)
{
Printf ("% d \ n", num );
}
}
Return 0;
} If you don't understand it, you can discuss it with Baidu.