题解 | #获取字符串长度#
获取字符串长度
http://www.nowcoder.com/practice/9a2d212d23f5436c80607d5e68c6d12a
#include using namespace std;
int main() {
int s=0;
char str[100] = { 0 };
int len =sizeof(str)/sizeof(str[0]);
cin.getline(str,100);
// write your code here......
for(int i=0;i<len;i++)
{
if(str[i]>='a'&&str[i]<='z'|| str[i]==' '||str[i]>='0'&&str[i]<='9')
{
s++;
}
}
cout<<s<<endl;
return 0;
}