11 条题解

  • 2

    gets不被需要了,所以我来拯救它

    #include <bits/stdc++.h>
    using namespace std;
    const int N=1e7+10;
    const int INF=0x3f3f3f3f;
    char a[2005];
    int main()
    {
    	gets(a);
    	int len=strlen(a),ans=0;
    	for(int i=0;i<len;i++)
    	{
    		if(a[i]>='0' && a[i]<='9')
    		{
    			ans++;
    		}
    	}
    	cout<<ans;
    }
    
    
    • 1
      @ 2023-9-24 8:58:02
      #include<bits/stdc++.h>
      #define LL long long
      using namespace std;
      const int INF=0x3f3f3f3f;
      const int N=2e5+10;
      string a;
      int sum=0;
      int main(){
      	getline(cin,a);
      	int b=a.size();
      	for(int i=0;i<b;i++){
      		if(a[i]>='0'&&a[i]<='9'){
      			sum++;
      		}
      	}
      	cout<<sum;
      	return 0;
      }
      
    • 1

      #include<iostream> #include<string> #include<cstring> using namespace std; const int N=2e5+10; char a[N]; int ans; int main() { cin.getline(a,255); int len = strlen(a); for(int i = 0;i <= len - 1;i++) { if(a[i] >= 48 && a[i] <= 57) { ans++; } } cout<<ans;

      return 0;
      

      }

      • 1
        @ 2023-4-22 15:52:35
        #include<cstdio>
        #include<string>
        #include<bits/stdc++.h>
        #define LL long long
        using namespace std;
        const int INF=0x3f3f3f3f;
        const int N=2e5+10;
        string a;
        int sum=0;
        int main(){
        	getline(cin,a);
        	int b=a.size();
        	for(int i=0;i<b;i++){
        		if(a[i]>='0'&&a[i]<='9'){
        			sum++;
        		}
        	}
        	cout<<sum;
        }
        
        
        • 1
          @ 2023-1-4 11:44:58
          #include<bits/stdc++.h>
          using namespace std;
          string str;
          int ans;
          int main()
          {
          	ios::sync_with_stdio(false);
          	cin.tie(0);
          	cout.tie(0);
          	getline(cin,str);
          	for(auto&i:str)
          	{
          		if(i>='0'&&i<='9')ans++;
          	}
          	printf("%d",ans);
          	return 0;
          }
          
          • 0
            @ 2024-12-8 18:21:45

            包没错!

            #include<string.h>
            #include<iostream>
            using namespace std;
            int main(){
            	char a[10010];
            	cin.getline(a,10000);
            	int len=strlen(a);
            	int sum=0;
            	for(int i=0;i<len;i++){
            		if(a[i]>='0' && a[i]<='9'){
            			sum++;
            		}
            	}
            	cout<<sum<<endl;
            }
            
            • 0
              @ 2024-5-7 17:33:13

              简单易懂👍 👍 👍

              #include<bits/stdc++.h>
              using namespace std;
              int main(){
              	string a;
              	cin>>a;
              	long long len=a.size(),sum=0;
              	for(int i=0;i<=len-1;i++){
                      if(a[i]>='0'&&a[i]<='9')
              		sum++;
              	
              	}
                  cout<<sum;	
              }
              
              • 0
                @ 2023-10-28 20:14:09

                #include<iostream> #include<cstring> using namespace std; const int N=255+10; const int INF=0x3f3f3f3f; char a[N]; int cnt; int main(){ cin.getline(a,255); int len=strlen(a); for(int i=0;i<len;i++) { if(a[i]>='0'&&a[i]<='9') { cnt++; } } cout<<cnt; }

                • 0
                  @ 2023-5-17 19:48:32
                  #include<iostream> 
                  #include<cmath>
                  #include<iomanip>
                  #include <cstring>
                  using namespace std;
                  int INF=0x3f3f3f3f;
                  const int N=255+10;
                  int ans;
                  char a[N];
                  int main()
                  {
                  	cin.getline(a,255);
                  	int len=strlen(a);
                  	for(int i=0;i<=len-1;i++)
                  	{
                  		if(a[i]>=48 && a[i]<=57)
                  		{
                  			ans++;
                  		}
                  	}
                  	cout<<ans;
                  	return 0;
                  }
                  
                  • -1
                    @ 2022-10-28 17:50:58
                    #include <iostream>
                    #include <stack>
                    #include <cmath>
                    #include <vector>
                    #include <string.h>
                    #include <queue>
                    #include <stdio.h>
                    #include <iomanip>
                    #include <cstdio>
                    #include <algorithm>
                    #define int long long
                    using namespace std;
                    const int N = 1e5 + 10;
                    const int INF = 0x3f3f3f3f;
                    signed main()
                    {
                    	char a;
                    	int cnt = 0;
                    	while(cin >> a)
                    	{
                    		if(a >= '0' && a <= '9')
                    		{
                    			cnt++;
                    		}
                    	}
                    	cout << cnt << endl;
                    	return 0;
                    }
                    
                    
                    • -3
                      @ 2022-1-23 20:18:26
                      #include <cstdio>
                      #include <string>
                      using namespace std;
                      
                      int main()
                      {
                          int cnt = 0;
                          string s;
                          getline(cin, s);
                          for (int i = 0; i < s.length(); i++) cnt += isdigit(s[i]);
                          cout << cnt << endl;
                          return 0;
                      }```
                      • 1

                      信息

                      ID
                      1140
                      时间
                      1000ms
                      内存
                      256MiB
                      难度
                      5
                      标签
                      递交数
                      640
                      已通过
                      254
                      上传者