1256 画8.cpp
来自「威士忌的HDU题解.大概有260多题的源码。对于学习非常有好处。」· C++ 代码 · 共 56 行
CPP
56 行
/*
1256 画8
Time Limit : 1000 ms Memory Limit : 32768 K Output Limit : 256 K
GUN C++
*/
#include <iostream.h>
using namespace std;
const int MAX=100;
int main()
{
int n,ca,high,cb,bold,temp,uplen,downlen,now;
char fill,line[MAX]={0},line2[MAX]={0};
cin>>n;
for(ca=0;ca<n;ca++)
{
cin>>fill>>high;
bold=1;temp=high;
while(temp>=6)
{ bold++;temp-=6;}
uplen=(high-3)/2;
downlen=high-3-uplen;
now=0;
for(cb=0;cb<bold;cb++,now++)
{ line[now]=' ';}
for(cb=0;cb<downlen;cb++,now++)//下圈内径为正方形
{ line[now]=fill;}
line[now]='\0';
now=0;
for(cb=0;cb<bold;cb++,now++)
{ line2[now]=fill;}
for(cb=0;cb<downlen;cb++,now++)
{ line2[now]=' ';}
for(cb=0;cb<bold;cb++,now++)
{ line2[now]=fill;}
line2[now]='\0';
//第一行
cout<<line<<endl;
for(cb=0;cb<uplen;cb++)
cout<<line2<<endl;
cout<<line<<endl;
for(cb=0;cb<downlen;cb++)
cout<<line2<<endl;
cout<<line<<endl;
if(ca!=n-1)
{ cout<<endl;}
}
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?