纯粹找规律的一小学数学题,空格处的数可有输入计算得出,每个6格三角形为一个计算单位。
#include <iostream> #include <cstdio> using namespace std; int tab[10][10]; int main() { int T; cin >> T; while (T--){ for (int i = 0; i <= 8; i += 2) for (int j = 0; j <= i; j += 2) cin >> tab[i][j]; for (int i = 0; i <= 6; i += 2) for (int j = 0; j <= i; j += 2){ int a = tab[i][j], b = tab[i + 2][j], c = tab[i + 2][j + 2]; tab[i + 1][j] = (a + b - c) / 2; tab[i + 1][j + 1] = (a - b + c) / 2; tab[i + 2][j + 1] = (a - b - c) / 2; } for (int i = 0; i <= 8; ++i) for (int j = 0; j <= i; j++) printf("%d%c", tab[i][j], j == i ? ' ' : ' '); } return 0; }