arrow_forward همه ارسال‌ها

جزئیات ارسال کد#573

code_blocks
مسئله مربوطه: الماس (#35) arrow_outward
verified
وضعیت داوری نهایی: پذیرفته شد
terminal
زبان برنامه‌نویسی: Python
schedule
ارسال‌کننده و زمان:
Milad Nasiri (۲ سال پیش)
descriptionsolution.py ۱۳ خط • ۳۴۳ بایت
1def print_diamond(n):
2 for i in range(n):
3 if i <= n // 2:
4 print(' ' * (n // 2 - i) + '*' * (2 * i + 1))
5 else:
6 print(' ' * (i - n // 2) + '*' * (2 * (n - i - 1) + 1))
7
8n = int(input())
9
10if n > 2 and n % 2 == 1:
11 print_diamond(n)
12else:
13 print("The number must be an odd number greater than 2.")
کد ارسال‌شده برای داوری خودکار هاتکدز UTF-8