C++用循环语句编程打印如下图案.

来源:百度知道 编辑:UC知道 时间:2024/05/25 11:52:53
#
###
#####
#######
#########
###########
#############
################
##################
####################

#include <iostream>
using namespace std;

int main()
{
for(int i=1; i<=10*3; i+=2)
{
for(int j=0; j<i; j++)
{
cout<<"#";
}
cout<< endl;
}
return 0;
}

#include <iostream>
using namespace std;

int main()
{
for(int i=1; i<=10*3; i+=2)
{
for(int j=0; j<i; j++)
{
cout<<"#";
}
cout<< endl;
}
return 0;
}
自己定义变量

分都没。打个毛。
不过还是好心给个思路你吧
for(i=0;i<10;i++)
{
for(j=0;j<i;j++)
{
printf("#");
}
printf("\n");
}
就是用一个嵌套循环
变量自己定义