?? 2-4.cpp
字號(hào):
#include<iostream>
#include<string>
using std::cin;
using std::cout;
using std::endl;
using std::string;
int main()
{
cout<<"Please enter your first name: ";
string name;
cin>>name;
const string greeting="Hello, "+name+"!";
int pad;
cout<<"Please enter pad: ";
cin>>pad;
const int rows=pad*2+3;
const int mid=rows/2;
const string::size_type cols=greeting.size()+pad*2;
cout<<endl;
for(int r=0;r!=rows;++r)
{
if(r==mid)
{
const string temp(pad,' ');
cout<<"*"<<temp<<greeting<<temp<<"*"<<endl;
}
else if(r==0||r==rows-1)
{
const string first(cols,'*');
cout<<"*"<<first<<"*"<<endl;
}
else
{
const string second(cols,' ');
cout<<"*"<<second<<"*"<<endl;
}
}
return 0;
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -