概述
1.输出
#include<iostream>
using namespace std;
int main()
{
for (int row=1;row<=4;row++)
{
for (int k = 1;k<row;k++)
{
cout << " ";
}
for (int i = 1;i <= row;i++)
{
cout << "#";
}
for (int j=1;j<=16-4*row;j++)
{
cout << " ";
}
for (int i = 1;i <= row;i++)
{
cout << "#";
}
cout << endl;
}
for (int row = 1;row <= 4;row++)
{
for (int k = 1;k<=4-row;k++)
{
cout << " ";
}
for (int i = 1;i <=5-row;i++)
{
cout << "#";
}
for (int j=1;j<=row*4-4;j++)
{
cout << " ";
}
for (int i = 1;i <= 5-row;i++)
{
cout << "#";
}
cout << endl;
}
system("pause");
return 0;
}
2.输出
#include<iostream>
using namespace std;
int main()
{
for (int j=0;j<4;j++)
{
/*for (int k=0;k<=j;k++)
{
cout << " ";
}*/
for (int i =0;i < 8-2*j;i++)
{
cout << "#";
}
cout << endl;
}
system("pause");
return 0;
}
3.输出
#include<iostream>
using namespace std;
int main()
{
for (int j=0;j<4;j++)
{
for (int k=0;k<=j;k++)
{
cout << " ";
}
for (int i =0;i < 8-2*j;i++)
{
cout << "#";
}
cout << endl;
}
system("pause");
return 0;
}
4.输出
#include<iostream>
using namespace std;
int main()
{
for (int j=0;j<3;j++)
{
for (int i=0;i<j+1;i++)
{
cout << "#";
}
cout << endl;
}
for (int j=0;j<4;j++)
{
for (int i = 0;i < 4-j;i++)
{
cout << "#";
}
cout << endl;
}
system("pause");
return 0;
}
最后
以上就是过时小伙为你收集整理的C++小练习:输出特殊图形的全部内容,希望文章能够帮你解决C++小练习:输出特殊图形所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复