程序描述
在几何学中,正方形是一种正规四边形,意味着它有四条相等的边和四个相等的角。
实心和空心正方形将如下所示

算法
对于实心正方形 -
Accept the Number of Rows from the user to draw the Solid Square For each Row, Print * for each Column to draw the Solid Square
对于空心正方形 −
Accept the Number of Rows from the user to draw the Hollow Square For the First and Last Row, Print * for each Column For the Remaining Rows, Print * for the first and Last Column.
Example
的中文翻译为:
示例
/* Program to print hollow and Solid Square pattern */
#include <stdio.h>
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("<p>");
for (r=1; r</p>
<p>");
}
printf("</p>
<p>");
/* Solid Square */
printf("Enter the Number of rows for Solid Square: ");
scanf("%d", &rows1);
printf("</p>
<p>");
for (r1=1; r1</p>
<p>");
}
getch();
return 0;
}</p></stdio.h>
输出

13万字C语言保姆级教程(深入):立即使用
在学习笔记中,你将探索c语言的核心概念和高级技巧!











