3 solutions

  • 8
    @ 2024-8-3 15:00:53
    #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;
    }
    
    • 1
      @ 2026-7-8 15:01:49
      #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
        @ 2026-5-6 16:00:25
        #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
        97
        Accepted
        39
        Uploaded By