`#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; }
`
微信直接扫码登录
使用经过邮箱注册的账号密码登录