打印如下图形:
ABCDEDCBA
ABCDCBA
ABCBA
ABA
A
C++:
#include <iostream>
using namespace std;
int main()
{
for(int i=1;i<=5;i++)
{
char char1='A';
for(int j=1;j<i;j++)
cout<<" ";
for(int n=1;n<=5-i+1;n++)
{
cout<<char1;
char1 += 1;
}
char1 -= 2;
for(int m=1;m<=5-i;m++)
{
cout<<char1;
char1 -= 1;
}
cout<<endl;
}
return 0;
}