标签:java
问题:
本题主要是对字符串输入的处理:
String a=cin.next();
char [] s=a.toCharArray();
2 asdfasdf123123asdfasdf asdf111111111asdfasdfasdf
6 9
代码:
import java.util.*; public class Main{ public static void main(String args[]){ Scanner cin=new Scanner(System.in); while(cin.hasNext()){ int n=cin.nextInt(); for(int i=0;i<n;i++){ String a=cin.next(); char [] s=a.toCharArray(); int sum=0; for(int j=0;j<s.length;j++){ if(s[j]>='0'&&s[j]<='9') sum+=1; } System.out.println(sum); } } } }
标签:java
原文地址:http://blog.csdn.net/amx50b/article/details/45798247