程序说明
打印如下所示的实心和空心菱形图案
算法
对于空心菱形 –
Accept the Number of Rows for Hollow Rhombus from the UserCreate 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 UserCreate 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
"); } printf("
"); printf("Enter the Number of rows for Solid Rhombus Pattern: "); scanf("%d", &rows1); printf("
"); for (r1=1; r1
"); } getch(); return 0;}
登录后复制
输出
以上就是在C语言中编写一个程序来打印实心和空心菱形图案的详细内容,更多请关注【创想鸟】其它相关文章!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。
发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/2585395.html