程序说明
打印左右箭头图案
算法
接受打印左右箭头图案的行数.
Print Upper Part of the Arrow with Stars PatternsPrint Inverted Right Triangle with Stars PatternsPrint Bottom Part of the Arrow with Stars PatternsPrint the Right Triangle with Stars Patterns
示例
/*Program to print the Left and right arrow pattern*/#includeint main() { int r, c, rows; //Left Arrow Pattern int r1, c1, rows1; //Right Arrow Pattern clrscr(); printf("Enter number of rows to print the Left Arrow Pattern: "); scanf("%d", &rows); printf(""); printf("The Left Arrow Pattern is:"); printf("
"); for(r=1; r<rows; r++){ for(c=1; c<=(rows-r); c++){ printf(" "); } for(c=r;c<=rows; c++){ printf("*"); } printf("
"); } for(r=1; r<=rows; r++){ for(c=1; c<r; c++){ printf(" "); } for(c=1; c<=r; c++){ printf("*"); } printf("
"); } printf("Enter number of rows to print the Right Arrow Pattern: "); scanf("%d", &rows1); printf("
"); printf("The Right Arrow Pattern is:"); printf("
"); for(r1=1; r1<rows1; r1++){ for(c1=1; c1<=(2*r1-2); c1++){ printf(" "); } for(c1=r1; c1<=rows1; c1++){ printf("*"); } printf("
"); } for(r1=1; r1<=rows1; r1++){ for(c1=1; c1<=(2*rows1 - 2*r1); c1++){ printf(" "); } for(c1=1; c1<=r1; c1++){ printf("*"); } printf("
"); } getch(); return 0;}
输出


立即学习“C语言免费学习笔记(深入)”;
以上就是在C语言中编写一个打印右箭头和左箭头图案的程序的详细内容,更多请关注创想鸟其它相关文章!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/1443916.html
微信扫一扫
支付宝扫一扫