Because the number of rows and columns in this arrangement have been fixed, it is better to find the rule. The complete number arrangement of the bottom row and the last three rows can be obtained from the bottom row, so the entire arrangement can be rolled out, my uugly code (I didn't use the last few rows of data in the question ):
#include<stdio.h>#include<iostream>#include<math.h>using namespace std;int main(){ int n;cin>>n; while(n--) { int temp,temp1,temp2,temp3,temp4,zhuan[10][10]; int a,b,c,d,e,f,g,h,i; cin>>temp;cin>>temp;cin>>temp; cin>>temp;cin>>temp;cin>>temp; cin>>temp1;cin>>temp2;cin>>temp3; cin>>temp4; cin>>a>>c>>e>>g>>i; b = (temp1 - a - c) / 2; d = (temp2 - e - c) / 2; f = (temp3 - e - g) / 2; h = (temp4 - g - i) / 2; zhuan[0][0] = a;zhuan[0][1] = b;zhuan[0][2] = c; zhuan[0][3] = d;zhuan[0][4] = e;zhuan[0][5] = f; zhuan[0][6] = g;zhuan[0][7] = h;zhuan[0][8] = i; for(int j = 1;j <=8 ;j++) for(int i = 0;i < 9 - j;i++) zhuan[j][i] = zhuan[j - 1][i] + zhuan[j - 1][i + 1]; for(int i = 8;i >= 0;i--) { for(int j = 0;j < 9 - i;j++) { if(j == 0) printf("%d",zhuan[i][j]); else printf(" %d",zhuan[i][j]); } printf("\n"); } } return 0;}