寫一程式可從鍵盤輸入整數n, 並在螢幕上印出大小為n的如下形狀(以n=3為例)
***
***
***
*
**
***
*
**
***
*
***
*****
*
***
*****
***
*
以下是範例程式:
/**
* Name: shape.c
* Subject: print out different shapes such as square, triangle, diamond
* Author: Your Name
* Begin Date: xx/xx/xxxx
* Last Update Date: xx/xx/xxxx
* Toolkit: gcc
*/
#include <stdio.h>
/**
* Your comment
*/
void square(int n) {
/* fill your code here */
}
/**
* Your comment
*/
void right_triangle(int n) {
/* fill your code here */
}
/**
* Your comment
*/
void left_triangle(int n) {
/* fill your code here */
}
/**
* Your comment
*/
void mid_triangle(int n) {
/* fill your code here */
}
/**
* Your comment
*/
void diamond(int n) {
/* fill your code here */
}
int main() {
int size;
printf("Please input the graph size: \n");
scanf("%d",&size);
/* 呼叫相關函數印出圖形 */
square(size);
right_triangle(size);
left_triangle(size);
mid_triangle(size);
diamond(size);
return(0);
}