แบบฝึกหัด ที่ 10

จงเขียน โดยใช้ ฟังค์ชั่น void drawRectangle(int height); ใส่ตัวเลขเพื่อนแสดงความสูงของสี่เหลี่ยม

สมมติใส่ 5 จะขึ้น

CCCCCC
CCCCCC
CCCCCC
CCCCCC
CCCCCC ความสูงจะได้ 5 แถว



#include
void drawRectangle(int height);
int main(void)
{
int height;
printf("Input height :");
scanf("%d",&height);
drawRectangle(height);
return 0;
}
void drawRectangle(int height)
{

while(height>0)
{
printf("cccccccccc\n");
height--;
}
}

6 ความคิดเห็น: