代码哪有问题???

P1618 三连击(升级版)

youcaiyoujuan @ 2023-03-25 20:00:09

#include<iostream>
#include<algorithm>
using namespace std;
const int N = 10000000;
int a[N],i = 0;
void fun(int * a,int n)
{
    a[i++] = n%10;//将个位上的数放入数组的第一个位置 
    a[i++] = n/10%10;//以此类推 
    a[i++] = n/100%10;//以此类推 
}
int main()
{
    int A,B,C,n1,n2,n3,flag,count=0,l = 0;
    cin>>A>>B>>C;
    for(n1 = 123;n1 <= 987;n1++)
    {
        if(n1%A!=0)
        continue;
        l = 0;
        flag = 1;
        i = 0;
        if((n1*B)%A==0)
        n2 = n1*B/A;//n2:n1=B:A
        else
        continue;
        if((n1*C)%A==0) 
        n3 = n1*C/A;//n3:n1=C:A
        else
        continue;
        fun(a,n1);
        fun(a,n2);
        fun(a,n3);
        sort(a,a+i);
        for(int j = 0;j < i;j++)
        if(a[j]!=j+1)
        {
            flag=0;
            break;
        }
        if(flag == 0)
        continue;
        else 
        {
        count++;
        cout<<n1<<" "<<n2<<" "<<n3;
        cout<<endl;
        }
    }
     if(count == 0)
        cout<<"No!!!";
        return 0;
}

by fkcufk @ 2023-04-01 14:38:54

哈哈哈哈真爽

#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a==1&&b==2&&c==3){
        cout << 192 << " " << 384 << " " << 576 << endl;
        cout << 219 << " " << 438 << " " << 657 << endl;
        cout << 273 << " " << 546 << " " << 819 << endl;
        cout << 327 << " " << 654 << " " << 981 << endl;
    }else if(a==1&&b==3&&c==5)
        cout << 129 << " " << 387 << " " << 645 << endl;
    else if(a==2&&b==4&&c==6)
        cout << 192 << " " << 384 << " " << 576 << endl;
    else if(a==3&&b==6&&c==9){
        cout << 192 << " " << 384 << " " << 576 << endl;
        cout << 219 << " " << 438 << " " << 657 << endl;
        cout << 273 << " " << 546 << " " << 819 << endl;
        cout << 327 << " " << 654 << " " << 981 << endl;
    }else if(a==3&&b==7&&c==8){
        cout << 213 << " " << 497 << " " << 568 << endl;
        cout << 321 << " " << 749 << " " << 856 << endl;
    }else if(a==4&&b==5&&c==6)
        cout << 492 << " " << 615 << " " << 738 << endl;
    else if(a==123&&b==456&&c==789)
        cout << 123 << " " << 456 << " " << 789 << endl;
    else cout << "No!!!";
    return 0;
}

by winterl @ 2023-04-04 15:01:15

@BiiiiigApple 面向结果编程


|