Untitled

 avatar
unknown
plain_text
2 months ago
586 B
5
Indexable
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main() 
{

    int n;
    scanf("%d", &n);
    
  	// Complete the code to print the pattern.
    int size = 2*n - 1;
    for (int i = 0; i < size; i++){
        for (int j = 0; j < size; j++){
            int min_row_dis = (i < size - i) ? i : size - i - 1;
            int min_col_dis = (j < size -j) ? j : size - j - 1;
            int min_dis = (min_row_dis < min_col_dis) ? min_row_dis : min_col_dis;
            printf("%i ", n - min_dis);
        }
        printf("\n");
    }
    
    return 0;
}
Leave a Comment