问题标题: 酷町堂:1760 错了

0
0
已解决
马奕阳
马奕阳
中级守护
中级守护

代码:

//100

//500

//12

#include<iostream>

using namespace std;

int sum;

int main(){

    int l,d,x;

    cin>>l>>d>>x;

    for(int i=l;i<=d;i++){

        while(1){

            sum+=i%10;

            i/=10;

            if(i<=0){

                break;

            }

        }

        if(sum==x){

            cout<<sum<<endl;

            break;

        }

        sum=0;

    }

    sum=0;

    for(int i=d;i>=l;i--){

        while(1){

            sum+=i%10;

            i/=10;

            if(i==0){

                break;

            }

        }

        if(sum==x){

            cout<<sum<<endl;

            break;

        }

        sum=0;

    }

    return 0;

}

哪里不对???

 


0
我要回答