Candy Dreamer
Time Limit: 1000MS Memory Limit: 65536KB
Problem Description
That's so annoying that ldq's nephew, ldh is always sticking to him! In order to gain a little peace, ldq determined to fulfill one of ldh's dream. For ldh, nothing is better than a tasty candy as he is a candy lover. But just ask for some candy? No, that's more or less simple! After a while, ldh came to ldq with the last edition of his little dream:
Give me a candy with the required size and ingredient(even the candy wrapper is made of it). The candy is a cylinder so you will know its diameter and length.
What a realistic but difficult-to-achieve dream, ldq thought. Somehow he has known that you have the ability to turn codes into real things(or say the ability to draw a candy), so help him, please!
Input
There are several cases of input, ending up with EOF.
For each case there is one line of input with three parameters:
- igr -- a non-blank character,represents the ingredient of the candy
- dia -- an integer,represents the diameter of the candy
- len -- an integer,represents the length of the candy
- (dia = 2k+1, k = 1,2,...; 1 < dia <= 25, 1 <= len <= 25) they are separated by spaces
Output
Output the figure of the candy, refering to the example output.
Be careful that there's a space between every two adjacent ingredients.
Every two adjacent cases are also seperated by a blank line.
Example Input
# 5 7
2 5 1
Example Output
# # # # # # # # #
# # # # # # # # # # # # #
# # # # # # # # # # # # # # #
# # # # # # # # # # # # #
# # # # # # # # #
2 2 2
2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2
2 2 2
#include<bits/stdc++.h>
using namespace std;
char mmp[30][100];
int main()
{
char s;
int n,m;
while(cin >> s >> n >>m)
{
memset(mmp,s,sizeof(mmp));
for(int i =0;i<n/2;i++)
{
for(int j = i+1;j < n-1-i;j++)
{
mmp[i][j] = ' ';
}
for(int j = i+1 +m+n-2;j < n-1-i +m+n-2;j++)
{
mmp[i][j] = ' ';
}
}
for(int i=n-1; i>n/2;i--)
{
for(int j = 0;j < 2*n+m-2;j++)
{
mmp[i][j] = mmp[n-1-i][j];
}
}
for(int i =0;i<n;i++)
{
for(int j = 0;j < 2*n+m-2-1;j++)
{
cout << mmp[i][j] << ' ';
}
cout << mmp[i][2*n+m-2-1] << endl;
}
cout << endl;
}
return 0;
}