首先此题很难去考虑字符串string等 毕竟“10”,“11”等不能直接由ASCALL码读出

考虑“拆分”

C++ 算法提高 计数问题

#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
    int n,count=0,i,x,t;
    cin>>n>>x;
    if(n<x)
    return 0;
    for(i=x;i<=n;i++)
    {
        for(t=i;t>0;t=t/10)
        {
            if(t%10==x)
            count++;
        }
        
    }
    cout<<count;
    return 0;
}

相关文章:

  • 2022-01-20
  • 2021-07-11
  • 2022-12-23
  • 2021-06-06
  • 2021-08-15
  • 2021-10-30
  • 2022-01-13
猜你喜欢
  • 2022-01-01
  • 2021-09-30
  • 2021-06-09
  • 2022-12-23
  • 2021-04-03
  • 2022-03-03
  • 2022-12-23
相关资源
相似解决方案