Cannot pass test cases while got correct output

i have used various for loop and if else conditions. suggest if there’s any better option to perform this question

@Yuganshu,
https://ide.codingblocks.com/s/228427 corrected code

Your logic and code is correct. Just print " " between every number and double spaces instead of single space for blank places.