急求以下c++程序

来源:百度知道 编辑:UC知道 时间:2024/06/16 11:15:46
以下为c++程序描述,我实在是做不上来了,求各位大侠帮帮我了~~~

C:\clang\topic05\less0516
Input the height of your V shape:3
*** ***
** **
**
C:\clang\topic05\less0516
Input the height of your V shape:5
***** *****
**** ****
*** ***
** **
**
C:\clang\topic05\less0516
Input the height of your V shape:7
******* *******
****** ******
***** *****
**** ****
*** ***
** **
**
急求啊,拜托各位了~~!!!!

#include <iostream>
#include <string>
using namespace std;

main() {
cout<<"Input the height of your V shape:";
int n;
cin>>n;
for(int i=n; i>=1; i--) {
if(i==1) cout<<"**"<<endl;
else {
string s(i,'*');
cout<<s<<" "<<s<<endl;
}
}
}

#include<iostream>
using namespace std;

class Triangle
{
public:
Triangle();
void Construct();
private:
int n;
};

Triangle::Triangle()
{
cout<<"Input the height of your V shape:";
cin>>n;
};

void Triangle::Construct()
{
int i,j;
for(i=n;i>=1;i--)
{
for(j=1;j<=n-i;j++)
cout<<' ';
for(j=1;j<=2*i;j++)
cou