T1103デジタル文字の数を数える

T11031桁の文字数を数える

「文字の行を入力し、その中の数字の数を数えます。」

入力フォーマット

1行の文字列で、全長は255を超えません。

出力フォーマット

出力は1行で、文字列の数字の数を出力します。(出力中の各行の終わりの余分なスペースは、回答の正確さに影響しません。)

サンプル入力

Peking University is set up at 1898.

サンプル出力

4

##コードは以下のように表示されます##

#include <iostream>
#include <cstring>
using namespace std;

int main(){
    
    
	char s[257];
	int count = 0;
	cin.getline(s,256);
	int l = strlen(s);
	for(int i=0; i<l; i++){
    
    
		if(s[i]>='0' && s[i]<='9')
			count ++;
	}
	cout << count;
	return 0;
}

おすすめ

転載: blog.csdn.net/qq_44524918/article/details/108603999