4 条题解

  • 1
    @ 2020-07-12 10:07:12

    #include<iostream>

    using namespace std;

    int count=0;
    int a,b;

    int main(){
    cin>>a>>b;
    for(int i=1;i<=a;i++){
    int ii=i;
    while(ii>0){
    if(ii%10==b)
    count++;
    ii=ii/10;
    }
    }

    cout<<count;

    return 0;
    }

  • 0
    @ 2023-10-15 21:31:14

    #include <stdio.h>

    int countDigit(int n, int x) {
    int count = 0;
    for (int i = 1; i <= n; i++) {
    int num = i;
    while (num > 0) {
    if (num % 10 == x) {
    count++;
    }
    num /= 10;
    }
    }
    return count;
    }

    int main() {
    int n, x;
    scanf("%d %d", &n, &x);

    int count = countDigit(n, x);

    printf("%d\n", count);

    return 0;
    }

  • 0
    @ 2022-06-30 18:49:01

    #include<iostream>
    using namespace std;

    int find(int i, int x)
    {
    int k = 0;

    while(i != 0)
    {
    if (i % 10 == x)
    k++;
    i /= 10;
    }
    return k;
    }

    int getNumber(int end,int x)
    {
    int i;
    int k = 0;
    for (i = 1; i <= end; i++)
    {
    k += find(i, x);
    }
    return k;
    }

    int main()
    {
    int end, x;
    cin >> end >> x;
    cout << getNumber(end, x);
    }

  • 0
    @ 2021-02-09 19:23:11

    函数每次使用;
    code:
    #include<iostream>
    using namespace std;
    int n,x,ans=0;
    int isx(int k)
    {
    while(k>0)
    {
    if(k%10==x) ans++;
    k/=10;
    }
    }
    int main(){
    cin>>n>>x;
    for(int i=1;i<=n;i++)
    isx(i);
    cout<<ans<<endl;
    return 0;
    }

  • 1

信息

ID
1153
难度
3
分类
(无)
标签
递交数
167
已通过
83
通过率
50%
上传者