返回题解分享
讨论 / 题解分享/ 帖子详情

作文标题 - 题解

`#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;
}

`
0 回复 0 转发 0 喜欢 2 阅读
回复 (0)
默认 最新
暂无回复,快来抢沙发!