Rejwan321 / CodeAssist

Contains coding problems solved by me
2 stars 2 forks source link

Solving problems in Hackerrank folder in C language. #6

Open Rejwan321 opened 6 months ago

Rejwan321 commented 6 months ago

Solve the C language codes in hacker rank and add your own solves to this repository. I will look over the code and tell you what changes to make.

saswasto commented 5 months ago

// Print a pattern of numbers from to as shown below. Each of the numbers is separated by a single space. Hacker rank problem solve.

include

include

include

include

int main() { int n; scanf("%d", &n); int size = 2 * n - 1; int grid[size][size]; for (int i = 0; i < n; i++) { for (int j = i; j < size - i; j++) { for (int k = i; k < size - i; k++) { grid[j][k] = n - i; } } } for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { printf("%d", grid[i][j]); if (j < size - 1) { printf(" "); } } printf("\n"); } return 0; }

Rejwan321 commented 5 months ago

Please specify the problem you solved