(Square of Asterisks) Write a function that displays at the left margin of the screen a solid square of asterisks whose side is specified in integer parameter side. For example, if side is 4, the function displays the following:
****
****
****
****
(Square of Asterisks) Write a function that displays at the left margin of the screen a solid square of asterisks whose side is specified in integer parameter side. For example, if side is 4, the function displays the following:
****
****
****
****
The input consists of n (0<n<100) lines.
Each line consists of the side length(ranges from 1 to 100).
The last line of input consists of Int(0).
Output a solid square of asterisks whose side is specified in integer parameter side for each input side length.
输入
1 2 3 4 0
输出
* ** ** *** *** *** **** **** **** ****
The main function is provided, you only need to complete the square function:
#include <iostream>
using namespace std;
void square( int ); // function prototype
int main()
{
unsigned int side = 0; // input side length
while (true)
{
cin>> side;
if (side == 0)
break;
square( side ); // display solid square of asterisks
cout << endl;
}
} // end main