在C语言中编写一个程序来打印实心和空心菱形图案

程序说明

打印如下所示的实心和空心菱形图案

算法

Accept the Number of Rows for Hollow Rhombus from the User
Create a Hollow Rhombus containing the same number of Rows specified by the User.
Print the first row containing the number of stars same as the number of rows.
Print the second row containing the first and last star as show in the output and leave the spaces between first and the last star.
Do the same till you reach the last Row.
Print the last row containing the number of stars same as the number of rows.

For Solid Rhombus −

Accept the Number of Rows for Solid Rhombus from the User
Create a Solid Rhombus containing the same number of Rows specified by the User.
Print the first row containing the number of stars same as the number of rows.
Do the same till you reach the last Row.

登录后复制

Example

的中文翻译为:

示例

/* Program to print Hollow and Solid Rhombus star pattern */
#include
int main() {
int r, c, rows; //Hollow Rhombus
int r1,c1, rows1; //Solid Rhombus
clrscr();
printf(“Enter the Number of rows for Hollow Rhombus Pattern: “);
scanf(“%d”, &rows);
printf(“

“);
for(r=1; r

发布于 2023-08-29 20:02:26
收藏
分享
海报
0 条评论
150
上一篇:如何在 C# 中重新抛出 InnerException 而不丢失堆栈跟踪? 下一篇:何时在C/C++中使用内联函数,何时不使用它?
目录

    0 条评论

    本站已关闭游客评论,请登录或者注册后再评论吧~

    忘记密码?

    图形验证码