有个问题绕不过来:写一个三角形

这是我自己码的程序,但是没想明白会什么出不了三角形。
小白一个,麻烦各位指导一下,谢谢了
#include
#include
using std::string;using std::cout;using std::endl;
int main()
{
const int h=5;
int hd=0;
while(hd!=h)
{
++hd;
int rows=0;
if(rows<=hd)
{
cout<<"*";
++rows;
}
cout<<endl;
}
return 0;
}
图片说明

这一句if(rows<=hd)
{
cout<<"*";
++rows;
}
改成:
for(rows=0;rows<=hd;rows++)
{
cout<<'"*";
}
cout<<endl;

int main()
{
    const int h=5;
    int hd=0;
    while(hd!=h)
    {
        ++hd;
        int rows=0;
        for(rows=0;rows<hd;rows++)
        {
            cout<<"*";
        }
        cout<<endl;
    }
    return 0;
}


这个是直角三角形

int main()
{
    const int h=5;
    int hd=0;
    while(hd!=h)
    {
        int rows=0;
        for(rows=0;rows<=hd;rows++)
        {
            cout<<"*";
        }
        ++hd;
        cout<<endl;
    }
    return 0;
}

这个也是直角三角形

int main(){
    int h=5;
    for (int i=1; i<=h; i++) {
        for (int j=1;j<=h-i; j++) {
            cout<<" ";
        }
        for (int j=0; j<2*i-1; j++) {
            cout<<"*";
        }
        cout<<"\n";
    }
    return 0;
}

试试这个 这个是等腰三角形