转载的老师发的答案,关注我,随时更新答案,如果来不及了,可以私信我,我发给你们相应的答案
#include
using namespace std;
void printA();
void printB();
void printC();
void printD();
void printAll();
int main()
{
printA();
printB();
printC();
printD();
cout << endl;
printAll();
return 0;
}
void printA()
{
for (int i = 1;i <= 10;++i)
{
for (int j = 1;j <= 10;++j)
{
cout << ((j <= i) ? “" : " ");
}
cout << endl;
}
}
void printB()
{
for (int i = 10;i >= 1;–i)
{
for (int j = 1;j <= 10;++j)
{
cout << ((j <= i) ? "” : " ");
}
cout << endl;
}
}
void printC()
{
for (int i = 10;i >= 1;–i)
{
for (int j = 10;j >= 1;–j)
{
cout << ((j <= i) ? “" : " ");
}
cout << endl;
}
}
void printD()
{
for (int i = 1;i <= 10;++i)
{
for (int j = 10;j >= 1;–j)
{
cout << ((j <= i) ? "” : " ");
}
cout << endl;
}
}
void printAll()
{
for (int i = 1, j = 10;i <= 10;++i, --j)
{
//A
for (int k = 1;k <= 10;++k)
{
cout << ((k <= i) ? “" : " ");
}
cout << " ";
//B
for (int k = 1;k <= 10;++k)
{
cout << ((k <= j) ? "” : " ");
}
cout << " ";
//C
for (int k = 10;k >= 1;–k)
{
cout << ((k <= j) ? “" : " ");
}
cout << " ";
//D
for (int k = 10;k >= 1;–k)
{
cout << ((k <= i) ? "” : " ");
}
cout << endl;
}
}