`#include<bits/stdc++.h>
using namespace std;
int main()
{
string str;
// cin>>str; //不可以用cin 直接输入字符串,它遇到空格会停止输入。
getline(cin,str);//而getline()可以输入整个字符串,包括空格。
int n=str.length();
int cnt=0;
for(int i=0;i<n;i++)
{
if(str[i]!=' ')cnt++;
}
cout<<cnt;
return 0;
}
`
using namespace std;
int main()
{
string str;
// cin>>str; //不可以用cin 直接输入字符串,它遇到空格会停止输入。
getline(cin,str);//而getline()可以输入整个字符串,包括空格。
int n=str.length();
int cnt=0;
for(int i=0;i<n;i++)
{
if(str[i]!=' ')cnt++;
}
cout<<cnt;
return 0;
}
`
0 回复
0 转发
0 喜欢
2 阅读



