程序描述
在几何学中,正方形是一种正规四边形,意味着它有四条相等的边和四个相等的角。
算法
对于实心正方形 –
Accept the Number of Rows from the user to draw the Solid SquareFor each Row, Print * for each Column to draw the Solid Square
登录后复制
对于空心正方形 −
立即学习“C语言免费学习笔记(深入)”;
Accept the Number of Rows from the user to draw the Hollow SquareFor the First and Last Row, Print * for each ColumnFor the Remaining Rows, Print * for the first and Last Column.
登录后复制
Example
的中文翻译为:
示例
/* Program to print hollow and Solid Square pattern */#include int main(){ int r, c, rows; //Hollow Rhombus int r1,c1, rows1; //Solid Rhombus clrscr(); /* Hollow Square */ printf("Enter the Number of rows for Hollow Square: "); scanf("%d", &rows); printf(""); for (r=1; r
"); } printf("
"); /* Solid Square */ printf("Enter the Number of rows for Solid Square: "); scanf("%d", &rows1); printf("
"); for (r1=1; r1
"); } getch(); return 0;}
登录后复制
输出
以上就是C语言中打印实心和空心正方形图案的程序的详细内容,更多请关注【创想鸟】其它相关文章!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。
发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/2584042.html