不会写C++ program~~帮帮

来源:百度知道 编辑:UC知道 时间:2024/05/17 03:36:29
print *:

-----*
----**
---***
--****
-*****
******
应该怎么写呢

#include<iostream>
using namespace std;
int main()
{
for(int i=0;i<6;i++)
{
for(int j=0;j<6;j++)
{
if(j<5-i)
cout<<" ";
else
cout<<"*";
}
cout<<endl;
}
system("pause");
return 0;
}

void main(void)
{
char str[7]="******";
for(int i=0;i<6;i++){
for(int j=0;j<6-i;j++)
str[j] = '-';
cout<<str<<endl;
}
}