解题代码
#include<cstdio>
#include<cmath>
int main()
{
int line, column;
char ele;
scanf("%d %c", &column, &ele);
line = (int)round((double)column / 2.0);
for (int i = 0; i < line; i++) {
if (i == 0 || i == line - 1) {
for (int j = 0; j < column; j++)
printf("%c", ele);
}
else {
for (int j = 0; j < column; j++) {
if (j == 0 || j == column - 1)
printf("%c", ele);
else printf(" ");
}
}
if (i != line - 1)
printf("\n");
}
return 0;
}
测试结果
问题整理
1.图形输出。