自己的IDE和洛谷的在线IDE结果不一样,求助
查看原帖
自己的IDE和洛谷的在线IDE结果不一样,求助
447927
lyx0楼主2021/8/30 15:52

如果把main函数里面的cin>>A>>B>>C;换成scanf("%d%d%d",&A,&B,&C);洛谷的在线IDE就显示正常结果了,这是为什么呢?

#include <iostream>
using namespace std;

bool check(int x,int y,int z){
    if(y>=999||z>=999) return 0;
    int b[10]={0};
    b[x%10]=1;b[x/10%10]=1;b[x/100]=1;
    b[y%10]=1;b[y/10%10]=1;b[y/100]=1;
    b[z%10]=1;b[z/10%10]=1;b[z/100]=1;
    for(int i=1;i<=10;++i){
        if(b[i]==0) return false;
    }
    return true;
}

int main(){
    int A,B,C;
    bool flag=1;
    cin>>A>>B>>C;
    for(int tmp=123;tmp<987;++tmp){
        if(tmp*B%A||tmp*C%A) continue;
        if(check(tmp,tmp*B/A,tmp*C/A))
            printf("%d %d %d\n",tmp,tmp*B/A,tmp*C/A),flag=0;
    }
    if(flag) printf("No!!!");
    return 0;
}

2021/8/30 15:52
加载中...