编写程序,用循环语句打印如下图案。

要求所有“*”号都有用单条语句cout<<'*';所有空格都用cout<<' ';回车用cout<<endl;来打印。

*
***
*****
*******
*********
***********
*************
***************
*****************

int n=9;
for(int i=0;i<n;i++) {
for(int j=1;j<n;j++) {
for(int k=0;k<i+j;k++)
cout<<'*'; }
cout'endl'; }
没调过,试试看追问

请将完整编程打出,我等下要考试啊啊啊

追答

#include
using namespace std;
int main() {
int n=9; //要输出的行数
for(int i=0;i<n;i++)

{
for(int j=1;j<n;j++)

{
for(int k=0;k<i+j;k++)
cout<<'*';
}
cout'endl';

}
return 0;

}

温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答