9 solutions

  • 1
    @ 2024-4-10 13:58:01
    #include <bits/stdc++.h>
    using namespace std;
    
    int main()
    {
    string temp;
    int sum=0;
    while(cin >> temp)
    {
    sum+=temp.size();
    }
    cout << sum << endl;
    return 0;
    }
    
    • 0
      @ 2024-4-11 22:55:51
      #include<bits/stdc++.h>
      using namespace std;
      int main(){
          string a; 
          string s;
          int b;cin>>b;//没用
          while(cin>>a){
              s+=a;
          }
          int number=0;
          for(int i=0;i<s.length();i++){
              if(s[i]!=' '){
              number++;
              }
          }
          cout<<number;
      }
      
      
      • 0
        @ 2024-4-9 16:35:20

        s=list(map(str,input().split())) ans=0 for word in s: for i in word: if i!=' ' and i!='\n': ans+=1 print(ans)

        • 0
          @ 2024-4-8 13:47:40

          `#include<bits/stdc++.h> using namespace std; int main() { string str; // cin>>str; //不可以用cin 直接输入字符串,它遇到空格会停止输入。 getline(cin,str);//而getline()可以输入整个字符串,包括空格。 int n=str.length(); int cnt=0; for(int i=0;i<n;i++) { if(str[i]!=' ')cnt++; } cout<<cnt; return 0; }

          `

          • 0
            @ 2024-4-7 15:01:23
            #include <iostream>
            #include <string>
            using namespace std;
            int main(){
            
            string str;
            int count=0;
            getline(cin,str);
            for(int i=0;i<str.size();i++){
            	if(str[i]!=' ')count++;
            }
            	cout<<count;
            	return 0;
            }
            
            
            • 0
              @ 2024-4-7 11:48:37
              import java.util.Scanner;
              
              public class Main {
              	public static void main(String[] args) {
              		Scanner sc = new Scanner(System.in);
              		String s = sc.nextLine();
              		sc.close();
              		String[] st = s.split(" ");
              		int sum = 0 ;
              		for (int i = 0; i < st.length; i++) {
              			sum += st[i].length();
              		}
              		System.out.println(sum);
              	}
              }
              
              • 0
                @ 2024-4-6 8:55:34
                #include<bits/stdc++.h>
                using namespace std;
                #define MaxSize 100
                
                int sum;
                
                int main(){
                	string str;
                	getline(cin,str);
                	
                	int n=str.length();
                	for(int i=0; i<n; i++){
                		if(str[i]!=' '&&str[i]!='\n')
                			sum++;
                	}
                	cout<<sum<<endl;
                	
                	return 0;
                }
                
                • 0
                  @ 2024-4-5 16:00:39

                  #include <bits/stdc++.h> #define int long long #define endl '\n' using namespace std; signed main(){ string str; getline(cin,str); int cut=0; for(int i=0;i<str.length();i++){ if(str[i]!=' ') { cut++;}} cout<<cut<<endl; return 0; }

                  • 0
                    @ 2024-4-5 9:34:16
                    #include <bits/stdc++.h>
                    using namespace std;
                    
                    int main()
                    {
                        int sum = 0;
                        string s;
                        getline(cin,s);
                        for(int i = 0;i < s.size();i++)
                        {
                            if(s[i] != ' ' && s[i] != '\n') sum++;
                        }
                        cout << sum;
                        return 0;
                    }
                    
                    • 1

                    Information

                    ID
                    10
                    Time
                    1000ms
                    Memory
                    256MiB
                    Difficulty
                    4
                    Tags
                    # Submissions
                    1122
                    Accepted
                    548
                    Uploaded By