URI Solution 1426 Add Bricks in The Wall - Solution in C++ | Ad Hoc
URI Online Judge Solution Add Bricks in The Wall| Ad Hoc
URI Main Problem Link - https://www.urionlinejudge.com.br/judge/en/problems/view/1426
Problem Name: URI Problem Add Bricks in The Wall
Problem Number : URI Problem 1426 Solution
Online Judge : URI Online Judge Solution
Level: Ad Hoc
Solution Language : C plus plus
URI Solution 1426 Code in CPP:
#include <cstdio> #include <cstring> using namespace std; int matriz[12][12]; int main(int argc, char const *argv[]) { int n, i, j; scanf("%d", &n); while(n--) { memset(matriz, 0, sizeof matriz); for (i = 0; i < 9; i += 2) for (j = 0; j <= (i + 1); j += 2) scanf("%d", &matriz[i][j]); for (i = 0; i < 8; i += 2) { for (j = 0; j <= (i + 1); j += 2) { matriz[i + 2][j + 1] = (matriz[i][j] - matriz[i + 2][j] - matriz[i + 2][j + 2]) / 2; matriz[i + 1][j] = matriz[i + 2][j] + matriz[i + 2][j + 1]; matriz[i + 1][j + 1] = matriz[i + 2][j + 1] + matriz[i + 2][j + 2]; } } for (i = 0; i < 9; ++i) { for (j = 0; j < (i + 1); ++j) { printf("%d", matriz[i][j]); if(j != i) printf(" "); } printf("\n"); } } return 0; }
No comments:
Write commentsTo know more about the problem, give us your valuable commment. We'll try to help you. Thanks