Đếm ký tự (THTB Đà Nẵng 2022)

View as PDF

Points: 300 Time limit: 1.0s Memory limit: 256M Input: demkt.inp Output: demkt.out

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

Example

Test 1

Input
CdqC9Cac8ac96c2369
Output
3
Note

Có 3 kí tự chữ số 9 trong xâu


Comments

  • zatarainbow 11:05 p.m. 4 dec, 2024
    #include<bits/stdc++.h>
    using namespace std;
    string a;
    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(nullptr);cout.tie(nullptr);
        freopen("demkt.inp","r",stdin);
        freopen("demkt.out","w",stdout);
        cin>>a;
        cout<<count(a.begin(),a.end(),57);
        return 0;
    }
    //code by https://youtube.com/@baongoccoder
    
    • p12a3PhamNguyenKhanhChi 12:29 p.m. 10 nov, 2024

      sao tui chạy trên python đúng rùi mà nộp thì sao nó ko ac mà cam lè vậy?????????????

      • Ziolesyama 2:10 p.m. 28 oct, 2024

        include<bits/stdc++.h>

        using namespace std;
        string S;
        long b=0;
        int main()
        {
        getline(cin,S);
        for(size_t i=0;i<S.length();++i)
        {
        if(S[i]=='9')
        b++;
        }
        cout<<b;
        return 0;
        }
        sao sai vay mn

        • p12b401 12:22 p.m. 22 oct, 2024

          The five boxing wizards jump quickly

          • tranvanphuc1950nb 8:41 p.m. 3 oct, 2024

            .

            • khanhchi2504 2:06 p.m. 27 sep, 2024

              code python đây
              import string
              f_r = open("demkt.inp","r")
              f_w = open("demkt.out","w")
              s = f_r.readline()
              dem = 0
              for i in s:
              if(i=='9'):
              dem = dem + 1
              f_w.write(str(dem))
              f_r.close()
              f_w.close()

              • TH06_2024 3:11 p.m. 5 sep, 2024

                too ezz bài cờ vua vô hạn có 100 thôi mà khó chết, bài 300 này thở còn đc điểm

                • Avocadorable 7:23 p.m. 23 feb, 2024
                  with open('demkt.inp', 'r') as f:
                      s = f.readline().strip()
                  
                  s = list(s)
                  
                  with open('demkt.out', 'w') as f:
                      f.write(str(s.count("9")) + '\n')
                  
                  • PY2FVoDinhDung 8:13 p.m. 27 jan, 2024

                    sao nhập xuất bằng file vậy?

                    • PY1FLePhuocMinhHung 6:37 p.m. 13 oct, 2023

                      mình chạy thử thì đúng mà sao làm vào đây lại bị Invalid Return nhỉ

                      • 6 more comments