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

前端 未结 10 1961
醉酒成梦
醉酒成梦 2021-01-07 14:41

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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-07 15:28

    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.

提交回复
热议问题