Print star ('*') diamond in C with nested loops?

前端 未结 10 1765
没有蜡笔的小新
没有蜡笔的小新 2021-01-07 14:59

I want to be able to print a diamond like this when the user enters 5 for the diamond. But also will work for any value that is odd and greater than 0.

10条回答
  •  难免孤独
    2021-01-07 15:24

    I don't want to give you the code, you should learn.

    The input number will be the width of the diamond, so make sure to make a relation between the spaces and asterisks that does not surpass this number.

    The main idea would be to start at 1 asterisk, and increment by two each time until the input number is reached.

    Also, do something to prevent an error if the user enters an even number.

提交回复
热议问题