- 论坛徽章:
- 0
|
#include<iostream>
#include<vector>
using namespace std;
string operate(vector<string>vLine,int width,int height,int style);
int main()
{
vector<string> vLine;
string str;
for(int i=0;i<3;i++)
{
cin>>str;
vLine.push_back(str);
}
string strRes=operate(vLine,5,5,0);
cout<<strRes<<endl;
return 0;
}
string operate(vector<string>vLine,int width,int height,int style)
{
string styleTab[10][9]={{" "," "," "," "," "," "," "," "," "}};//for test ,只先给出一种样式
int length=vLine.size();
if(0==length){
cout<<"文字长度为0,请核查!"<<endl;
cin.get();
exit(1);
}
int index = 0;
string v_ary[100][100];
while(index <length)
{
for(int i=width*2; i>=0; i--)
{
for(int j=0; j<=(height+1); j++)
{
if( i == (width * 2))//至右
{
if(j==0)
{
v_ary[i][j] = styleTab[style][1];//右上角
}
else if(j == (height + 1))
{
v_ary[i][j] = styleTab[style][3];//右下角
}
else
{
v_ary[i][j] = styleTab[style][6];//右中
}
}
else if ( i== 0)//至左
{
if(j==0)
{
v_ary[i][j] = styleTab[style][0];//左上角
}
else if(j == (height + 1)){
v_ary[i][j] = styleTab[style][2];//左下角
}
else{
v_ary[i][j] = styleTab[style][6];//左中
}
}
else if( i % 2 == 0)//横向定位
{
if(j==0)//部份顶部
{
v_ary[i][j] = styleTab[style][4];
}
else if(j == (height + 1))//部份底部
{
v_ary[i][j] = styleTab[style][5];
}
else //中部
{
v_ary[i][j] = styleTab[style][7];
}
}
else if(j == 0 || j == (height + 1)) //补齐顶,底部
{
v_ary[i][j] = styleTab[style][8];
}
else//文字登场
{
cout<<vLine[index]<<endl;
string c=vLine[index];
if (c == "\n" || c == "\r")
{
while(j<(height+1))//遇到换行或是回车将本竖行其余空格补满
{
v_ary[i][j] =' ';
j++;
}
j = height;
}
else
{
v_ary[i][j] = c;//填充文字
}
index++;
}
}//for j
}//for i
}//while
}
|
|
|