Đếm chữ số lẻ (THT TP 2019)

View as PDF



Author:
Problem type
Points: 100 (p) Time limit: 1.0s Memory limit: 256M Input: stdin Output: stdout

Nhập vào từ bàn phím một xâu kí tự \(S\) (có không quá \(255\) kí tự) chỉ chứa các kí tự chữ số từ \(0\) đến \(9\). Hãy đếm trong xâu \(S\) có bao nhiêu kí tự chữ số lẻ và in kết quả ra màn hình

Input

  • Một xâu kí tự \(S\)

Output

  • Kết quả của bài toán

Example

Test 1

Input
2019 
Output
2

Comments

  • ducbao_ 9:01 p.m. 14 dec, 2024
    #include <iostream>
    #include <string>
    
    using namespace std;
    
    int main() {
        string s;
        int cnt=0;
        cin >> s;
        for (char c : s) {
            if (c == '1' || c == '3' || c == '5' || c == '7' || c == '9') {
                cnt++;
            }
        }
        cout << cnt << endl;
        return 0;
    
    }
    
    • giathinhd061 10:19 a.m. 17 jul, 2024

      s = input()
      ct = 0
      for i in s:
      if int(i) % 2 != 0:
      ct += 1
      print(ct)

      • Avocadorable 8:10 p.m. 21 may, 2024
        s = input()
        ct = 0
        for i in s:
            if int(i) % 2 != 0:
                ct += 1
        print(ct)
        
        • hjhjhjhjhj 9:16 a.m. 6 apr, 2024

          include <bits/stdc++.h>

          using namespace std;
          int main(){
          string s; cin >> s;
          int d = 0;
          for (char&i:s) if ((i-'0')%2!=0) d ++ ;
          cout << d ;
          return 0;
          }
          c++

          • NguyenHuy2501 6:16 p.m. 4 jan, 2024 edited

            bai nay khó

            • no2k8 10:40 a.m. 16 oct, 2022

              This comment is hidden due to too much negative feedback. Click here to view it.

              • iqtop09 3:35 p.m. 7 jul, 2022

                tưởng ko dễ ai ngờ dễ ko tưởng

                • minhtuanitk20 10:01 p.m. 27 sep, 2021

                  This comment is hidden due to too much negative feedback. Click here to view it.