10 条题解

  • 2
    @ 2023-5-17 20:28:21

    #include<bits/stdc++.h> using namespace std; const int N=1e3+10; char a[N];

    bool flag=0; int main(){ while(cin>>a){ if(flag){ cout<<","; }else{ flag=1; } cout<<strlen(a); }

    return 0;
    

    }

    • 2
      @ 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;
      }
      
      • 1
        #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-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-4-21 20:55:18

                #include<cstdio>

                #include<cstring>

                #include<iostream>

                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;
                  }
                  
              • -1
                @ 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;
                }
                
                • -1
                  @ 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
                    @ 2021-10-9 20:19:50

                    #include<iostream> #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
                    标签
                    递交数
                    629
                    已通过
                    188
                    上传者