Tsinsen A1114 寻找三位数

http://www.tsinsen.com/A1114

分析:…懒得打表

代码:

#include "bits/stdc++.h"
using namespace std;

int main() {
    int a[9] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
    do {
        int A = 100 * a[0] + 10 * a[1] + a[2];
        int B = 100 * a[3] + 10 * a[4] + a[5];
        int C = 100 * a[6] + 10 * a[7] + a[8];
        if (A + A == B && A + B == C)
            printf("%d %d %d\n", A, B, C);
    } while (next_permutation(a, a + 9));
    return 0;
}

你可能感兴趣的:(ACM-01)