您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

在C语言中编写一个打印右箭头和左箭头图案的程序

2024/5/26 5:15:21发布29次查看
程序说明打印左右箭头图案
算法接受打印左右箭头图案的行数.
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*/#include<stdio.h>int 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语言中编写一个打印右箭头和左箭头图案的程序的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product