輸入一行字符,統計出其中數字字符的個數。ios
Peking University is set up at 1898.
4
1 #include<iostream> 2 #include<cstring> 3 #include<cstdio> 4 using namespace std; 5 int main() 6 { 7 8 char a[256]; 9 int num=0,l; 10 gets(a); 11 l=strlen(a); 12 for(int i=0;i<l;++i) 13 { 14 if(a[i]>='0'&&a[i]<='9') 15 { 16 ++num; 17 } 18 } 19 cout<<num; 20 return 0; 21 }