打印左右箭头图案
接受打印左右箭头图案的行数.
Print Upper Part of the Arrow with Stars Patterns Print Inverted Right Triangle with Stars Patterns Print Bottom Part of the Arrow with Stars Patterns Print 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("</p><p>");
printf("The Left Arrow Pattern is:");
printf("</p><p>");
for(r=1; r<rows; r++){
for(c=1; c<=(rows-r); c++){
printf(" ");
}
for(c=r;c<=rows; c++){
printf("*");
}
printf("</p><p>");
}
for(r=1; r<=rows; r++){
for(c=1; c<r; c++){
printf(" ");
}
for(c=1; c<=r; c++){
printf("*");
}
printf("</p><p>");
}
printf("Enter number of rows to print the Right Arrow Pattern: ");
scanf("%d", &rows1);
printf("</p><p>");
printf("The Right Arrow Pattern is:");
printf("</p><p>");
for(r1=1; r1<rows1; r1++){
for(c1=1; c1<=(2*r1-2); c1++){
printf(" ");
}
for(c1=r1; c1<=rows1; c1++){
printf("*");
}
printf("</p><p>");
}
for(r1=1; r1<=rows1; r1++){
for(c1=1; c1<=(2*rows1 - 2*r1); c1++){
printf(" ");
}
for(c1=1; c1<=r1; c1++){
printf("*");
}
printf("</p><p>");
}
getch();
return 0;
}

立即学习“C语言免费学习笔记(深入)”;
以上就是在C语言中编写一个打印右箭头和左箭头图案的程序的详细内容,更多请关注php中文网其它相关文章!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号