HDU 2017 string statistics, hdu2017 string statistics

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.