难度:⭐
思维程度:2
题目位置:链接
因为要判断一个字符串中是是有数字。
所以不得不用char数组。
不知道长度的char数组可以用scanf()。
代码:
#include<bits/stdc++.h>
using namespace std;
int main()
{
char a[260];
int s;
scanf("%s",a);
for(int i=0;i<strlen(a);i++)
{
if(a[i]>='0'||a[i]<='9')
{
s++;
}
}
cout<<s;
return 0;
}
放心,每天都有。