16 条题解

  • 1
    @ 2025-12-14 9:39:30
    #include<bits/stdc++.h>
    using namespace std;
    const int N=1e3+10;
    int cnt=0;
    char a[N];
    int main()
    {
    	cin.getline(a,1010);
    	int len=strlen(a);
    	a[len]=' ';
    	int flag=0;
    	for(int i=0;i<=len;i++)
    	{
    		if(a[i]!=' ')
    		{
    			cnt++;
    		}
    		else if(cnt!=0)
    		{
    			if(flag)
    			{
    				cout << ',';
    			}
    			cout << cnt ;
    			flag=1;
    			cnt=0; 
    		}
    	}
    	return 0;
    }
    
    
    • 1
      @ 2024-11-15 20:24:12
      #include <stdio.h>
      #include <iostream>
      #include <string.h>
      using namespace std;
      char a[100000],b[100000];
      int main()
      {
      	cin.getline(a,100000);
      	int len = strlen(a);
      	a[len]= ' ';
      	int num = 0 , flag = 0;
      	for(int i = 0 ; i <= len ; i++)
      	{
      		if(a[i] != ' ')
      			num++;
      		else if(num != 0) 
      		{
      			if(flag)
      				cout << ",";
      			cout << num;
      			flag = 1;
      			num = 0;
      		}
      	}
      }
      
      • 1
        @ 2023-9-17 19:37:18
        #include <iostream>
        #include <bits/stdc++.h>
        using namespace std;
        const int N=1e7+10;
        const int INF=0x3f3f3f3f;
        char a[505];
        bool f=0;
        int main()
        {
        	while(cin>>a)
        	{
        		if(f==1)
        		{
        			cout<<","<<strlen(a);
        		}
        		else
        		{
        		    cout<<strlen(a);
        		    f=1;
        		}
        	}
        	
        }
        
        
        • 0
          @ 2025-1-25 11:25:13
          #include<iomanip>
          #include<cmath>
          #include<cstring>
          #include<algorithm>
          using namespace std;
          const int N=1e3+10;
          const int INF=0x3f3f3f3f;
          //char a[N];
          int ans;
          string a; 
          bool flag; 
          int main()
          {
          	while(cin>>a)
          	{
          		if(!flag)
          			flag=1;
          		else
          			cout<<",";
          		cout<<a.size(); 
          	}
          	return 0;
          }
           
          
          • 0
            @ 2025-1-25 11:21:14
            #include <iostream>
            #include <bits/stdc++.h>
            using namespace std;
            const int N=1e7+10;
            const int INF=0x3f3f3f3f;
            char a[505];
            bool f=0;
            int main()
            {
            while(cin>>a)
            {
            if(f==1)
            {
            cout<<","<<strlen(a);
            }
            else
            {
            cout<<strlen(a);
            f=1;
            }
            }
            
            }
            
            
            • 0
              @ 2024-1-30 11:19:46
              #include<cmath>
              #include<iomanip>
              #include <cstring>
              using namespace std;
              int INF=0x3f3f3f3f;
              const int N=1e3+10;
              int ans;
              bool f;
              char a[N];
              int main()
              {
              	while(cin>>a)
              	{
              		if(f)
              		{
              			cout<<",";
              		}
              		else
              		{
              			f=1;
              		}
              		int len=strlen(a);
              		cout<<len;
              	}
              	return 0;
              }
              `
              
              | col1
              
              | col1
              
              | col1 | col2 | col3 |
              | --- | --- | --- |
              |  |  |  |
              |  |  |  | | col2 | col3 |
              | --- | --- | --- |
              |  |  |  |
              |  |  |  | | col2 | col3 |
              | --- | --- | --- |
              |  |  |  |
              |  |  |  |`
              
              • 0
                @ 2023-5-17 20:25:38
                #include<iostream> 
                #include<cmath>
                #include<iomanip>
                #include <cstring>
                using namespace std;
                int INF=0x3f3f3f3f;
                const int N=1e3+10;
                int ans;
                bool f;
                char a[N];
                int main()
                {
                	while(cin>>a)
                	{
                		if(f)
                		{
                			cout<<",";
                		}
                		else
                		{
                			f=1;
                		}
                		int len=strlen(a);
                		cout<<len;
                	}
                	return 0;
                }
                
                • 0
                  @ 2023-4-16 19:39:35
                  #include <bits/stdc++.h>
                  using namespace std;
                  string s;
                  int dc[305],z=0,d=0;
                  int main()
                  {
                    memset(dc,0,sizeof(dc));
                    getline(cin,s);
                    for(int i=0; i<s.size(); i=i+1)
                    {
                      if(s[i]!=' ')d=d+1;
                      else
                      {
                        if(d!=0)
                        {
                          z=z+1;
                          dc[z]=d;
                          d=0;
                        }
                      }
                    }
                    if(d>0)
                    {
                      z=z+1;
                      dc[z]=d;
                    }
                    printf("%d",dc[1]);
                    for(int i=2; i<=z; i=i+1)printf(",%d",dc[i]);
                    return 0;
                  }
                  
                  • 0
                    @ 2023-1-22 22:36:59
                    #include <bits/stdc++.h>
                    using namespace std;
                    string s;
                    int dc[305],z=0,d=0;
                    int main()
                    {
                      memset(dc,0,sizeof(dc));
                      getline(cin,s);
                      for(int i=0; i<s.size(); i=i+1)
                      {
                        if(s[i]!=' ')d=d+1;
                        else
                        {
                          if(d!=0)
                          {
                            z=z+1;
                            dc[z]=d;
                            d=0;
                          }
                        }
                      }
                      if(d>0)
                      {
                        z=z+1;
                        dc[z]=d;
                      }
                      printf("%d",dc[1]);
                      for(int i=2; i<=z; i=i+1)printf(",%d",dc[i]);
                      return 0;
                    }
                    
                    • 0
                      @ 2022-10-24 23:05:02
                      #include<iostream>
                      #include<algorithm>
                      using namespace std;
                      int main(){
                      	string str;
                      	int first=0;
                      	while(cin>>str){
                      		if(first==1)
                      			cout<<",";
                      		first=1;
                      		cout<<str.size();
                      	}
                          return 0;
                      }
                      
                      • 0
                        @ 2022-4-21 20:55:18

                        #include

                        #include

                        #include

                        using namespace std;

                        char a[1001];

                        int n,s;

                        int main(){

                        gets(a);//输入 
                        
                        n=strlen(a);//长度 
                        
                        for(int i=0;i<n;i++)
                        
                        {
                        
                        	if(a[i]==' ')
                        
                        	{
                        
                        	if(s>0)
                        
                        	printf("%d,",s);
                        
                        	s=0;
                        
                        	}
                        
                        	else
                        
                        	s++;
                        
                        }
                        
                        printf("%d",s);
                        
                        return 0;
                        

                        }

                        //75分代码,求改正

                        • @ 2023-1-23 18:13:27

                          你漏了这种情况: 输入"abcde--xyz 123bha "读入:"10,6,0"应为:"10,6" 可以改成:

                          #include<cstdio>
                          #include<cstring>
                          #include<iostream>
                          using namespace std;
                          char a[1001];
                          int n,s;
                          bool b=false;//标记是否第一个输出
                          int main(){
                              gets(a);//输入 
                              n=strlen(a);//长度 
                              for(int i=0;i<n;i++)
                              {
                                  if(a[i]==' ')
                                  {
                                      if((s>0)&&(b==true))printf(",%d",s);
                                      if((s>0)&&(b==false)){
                                          printf("%d",s);
                                          b=true;
                                      }
                                      s=0;
                                  }
                                  else s++;
                              }
                              if((s>0)&&(b==false))printf("%d",s);
                              if((s>0)&&(b==true))printf(",%d",s);
                              return 0;
                          }
                          
                      • 0
                        @ 2022-1-23 20:09:46
                        #include <bits/stdc++.h>
                        using namespace std;
                        int main() {
                            string s;
                            bool flag = true;
                            while (cin >> s) {
                                if (flag) {
                                    flag = false;
                                    cout << s.size();
                                } else {
                                    cout << ',' << s.size();
                                }
                            }
                            return 0;
                        }
                        • -1
                          @ 2025-1-25 11:22:02

                          👎

                          • -1
                            @ 2025-1-25 11:19:39
                            
                            

                            #include #include <bits/stdc++.h> using namespace std; const int N=1e7+10; const int INF=0x3f3f3f3f; char a[505]; bool f=0; int main() { while(cin>>a) { if(f==1) { cout<<","<<strlen(a); } else { cout<<strlen(a); f=1; } }

                            }

                            
                            
                            • -1
                              @ 2024-12-13 20:20:14

                              看我干啥

                              • -1
                                @ 2021-10-9 20:19:50

                                #include #include<string.h> using namespace std; int main() { char a[1001]; cin.getline(a,1001); int len=strlen(a); int flag=1; int num=0; for(int i=0;i<len;i++) { if(a[i]!=' ') num++; else if(i>0) { if(a[i-1]' ') continue; if(flag0) cout<<","; flag=0; cout<<num; num=0; } } if(num != 0) { if(flag==0) cout<<","; cout<<num; } }

                                • 1

                                信息

                                ID
                                1095
                                时间
                                1000ms
                                内存
                                128MiB
                                难度
                                6
                                标签
                                递交数
                                971
                                已通过
                                321
                                上传者