#python #anaconda #jupyter-notebook #visual-code #html #css #javascript #http

제목작년 중간고사 SWCON104-01 2번 예시답안입니다.2019-10-17 20:18
작성자
#이것보다 깔끔하고 좋은 코드도 있으니, 참고용으로 사용하세요.

inputnum = int(input("input: "))
for row in range(inputnum+1):
    if(row != 0):
        for col in range(inputnum+1):
            if(col != 0):
                if col>row:
                    print('+'.ljust(5), end = '')
                elif col<row:
                    if row % 2 == 0 and col % 2 == 0:
                        print('*'.ljust(5),end='')
                    else:
                        print(str(col+row).ljust(5),end='')
                else:
                    print('-'.ljust(5),end='')
            else:
                print(str(row).ljust(5),end='')
    else:
        print(' '.ljust(5),end='')
        for i in range(1,inputnum+1):
            print(str(i).ljust(5),end='')
    print('')

 
댓글