1 #include <iostream> 2 using namespace std; 3 int main(int argc, char** argv) { 4 int n; 5 cin>>n; 6 //三角 7 for(int i=1;i<=n;i++){ 8 for(int t=1;t<=n-i;t++){ 9 cout<<" "; 10 } 11 for(int r=65;r<2*i-1+65;r++){ 12 cout<<char(r); 13 } 14 cout<<endl; 15 } 16 //菱形 17 for(int i=1;i<=n;i++){ 18 for(int t=1;t<=n-i;t++){ 19 cout<<" "; 20 } 21 for(int r=65;r<2*i+64;r++){ 22 cout<<char(r); 23 } 24 cout<<endl; 25 } 26 for(int i=n-1;i>=1;i--){ 27 for(int t=1;t<=n-i;t++){ 28 cout<<" "; 29 } 30 for(int r=65;r<2*i+64;r++){ 31 cout<<char(r); 32 } 33 cout<<endl; 34 } 35 //平行四边形 36 cout<<endl; 37 for(int i=n;i>=1;i--){ 38 for(int t=1;t<=n-i;t++){ 39 cout<<" "; 40 } 41 for(int r=65;r<n+65;r++){ 42 if(r-64==i){ 43 cout<<"|"; 44 }else{ 45 cout<<char(r); 46 } 47 48 } 49 cout<<endl; 50 } 51 return 0; 52 }
标签:std,规律,int,c++,--,main From: https://www.cnblogs.com/liujiaxing-/p/18076153