2 solutions
-
8
#include<bits/stdc++.h> using namespace std; const int N=10010; char a[N]; int main() { cin.getline(a,N); int n=strlen(a); for (int i=0;i<n;i++) { if (a[i]==' ') { continue; } int j=i; while(j<n&&a[j]!=' ') j++; j--; int len=j-i+1; if (i==0) cout<<len; else cout<<","<<len; i=j; } return 0; } -
0
#include<bits/stdc++.h> using namespace std; int main() { string s; getline(cin,s); int n=s.size(); string long_,short_; for(int i=0;i<n;i++) { if(s[i]==' '||s[i]==',') continue; int j=i; while(j<n&&!(s[j]==' '||s[j]==',')) j++; j--; string s1=s.substr(i,j-i+1); i=j; if(long_.empty()) { long_=s1; short_=s1; } int m=s1.size(); if(m>long_.size()) { long_=s1; } if(m<short_.size()) { short_=s1; } i=j; } cout<<long_<<endl; cout<<short_<<endl; return 0; }
- 1
Information
- ID
- 86
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 3
- Tags
- # Submissions
- 96
- Accepted
- 38
- Uploaded By