题解 | 字符串最后一个单词的长度
字符串最后一个单词的长度
https://www.nowcoder.com/practice/8c949ea5f36f422594b306a2300315da
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <map>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>//队列
#include <stack> //栈
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define pii pair<int, int>
//queue<int> que;
//set<int> s;
//stack<int> st;
void solve() {
//scanf("%d", &);
//printf("\n", );
/*
cout << "手慢无" << endl;
cout << "骗你的,手快也无" << endl;
cout << "haha ^_^" << endl;
*/
//vector<int>a(n);
//sort(a.begin(), a.end());
//map<int, int>mp;
int len=0;
string s;
while(cin>>s)
{
len=s.size();
}
cout<<len;
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t = 1;
//cin >> t;
while (t--) {
solve();
cout << endl;
}
return 0;
}
#牛客春招刷题训练营#
查看18道真题和解析