程序描述
这是一个四边形,其中两对对边是平行的。

有六个重要的平行四边形属性需要了解
- 对边相等 (AB = DC)。
- 对角线相等 (D = B)。
- 相邻角互补 (A + D = 180°)。
- 如果一个角是直角,则所有角都是直角。
- 平行四边形的对角线互相平分。
- 平行四边形的每条对角线将其分成两个相等的部分。
算法
- 从用户那里接受行数和列数。将其存储在rows和cols变量中。
- 为了迭代行,运行一个外部循环,循环结构应该是for(r=1; r
- 为了打印空格,运行一个内部循环,循环结构为for(c=1; c
- 打印星号以形成空心的平行四边形,运行另一个内部循环,循环结构为for(c=1; c
- 在打印完一行的所有列之后,换行,即打印新的一行。
示例
// C program to print mirrored hollow parallelogram #includeint main(){ int rows,cols,r,c; clrscr(); /*Clears the Screen*/ printf("Please enter the number of Rows: "); scanf("%d", &rows); printf(" "); printf("Please enter the number of Columns: "); scanf("%d", &cols); printf("
"); printf("The Mirrored Hollow Parallelogram is: "); printf("
"); for(r = 1; r <= rows; r++){ // Display spaces for(c = 1; c < r; c++) { printf(" "); } // Display hollow parallelogram for(c = 1; c <= cols; c++) { if (r == 1 || r == rows || c == 1 || c == cols) { printf("*"); } else { printf(" "); } } printf("
"); } getch(); return 0; }
输出

立即学习“C语言免费学习笔记(深入)”;













