given a number n and we have to print the arrow star pattern of maximum n number of stars.
The star pattern of input 4 will look like −
Example
Input: 3Output:
登录后复制
Input: 5Output:
登录后复制
下面使用的方法如下:
以整数形式输入。然后打印n个空格和n个星号。递减直到n>1。现在递增直到n。并按照递增顺序打印空格和星号。
算法
StartIn function int arrow(int num) Step 1-> declare and initialize i, j Step 2-> Loop For i = 1 and i Loop For i = 2 and i declare and initialize num = 4 Step 2-> call arrow(num)
登录后复制
Example
演示
#include // arrow functionint arrow(int num) { int i, j; // Prints the upper part of the arrow for (i = 1; i"); } // Prints lower part of the arrow for (i = 2; i
"); } return 0;}int main() { // get the value from user int num = 4; // function calling arrow(num); return 0;}
登录后复制
输出
如果运行上述代码,将生成以下输出 −
以上就是C程序的箭头星型图案的详细内容,更多请关注【创想鸟】其它相关文章!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。
发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/2587943.html