📄 2-5.cpp
字号:
#include<iostream>
#include<string>
using std::cout;
using std::cin;
using std::endl;
using std::string;
int main()
{
{
cout<<"Please enter the longth of the square: ";
int longth;
cin>>longth;
const string cheng((longth-2)*2+1,' ');
const string ning((longth-2)*2+1,'*');
for(int i=0;i<longth;++i)
{
if(i==0||i==longth-1)
cout<<"*"<<ning<<"*"<<endl;
else
cout<<"*"<<cheng<<"*"<<endl;
}
}
{
cout<<"Please enter the longth of the oblong: ";
int longth;
cin>>longth;
cout<<"Please enter the breadth of the oblong: ";
int breadth;
cin>>breadth;
const string cheng((longth-2)*2+1,' ');
const string ning((longth-2)*2+1,'*');
for(int i=0;i<breadth;++i)
{
if(i==0||i==breadth-1)
cout<<"*"<<ning<<"*"<<endl;
else
cout<<"*"<<cheng<<"*"<<endl;
}
}
{
cout<<"Please enter the border of the triangle: ";
int border;
cin>>border;
int mid=15;
for(int i=0;i<border;++i)
{
const string cheng((mid-i)*2,' ');
if(i==0)
cout<<cheng<<"*"<<endl;
else
{
if(i==border-1)
{
const string ning(3+(i-1)*4,'*');
cout<<cheng<<"*"<<ning<<"*"<<endl;
}
else
{
const string ning(3+(i-1)*4,' ');
cout<<cheng<<"*"<<ning<<"*"<<endl;
}
}
}
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -