1.三角形
#include <iostream> using namespace std; int main() { int t; cin>>t; int n = 65; for(int i = 1;i<=t;i++){ for(int j = 1;j<=t-i;j++){ cout<<" "; } for(int j = 1;j<=i*2-1;j++){ cout<<char(n); n++; } cout<<endl; n = 65; } return 0; }
2.菱形
#include <iostream> using namespace std; int main() { int t; cin>>t; int n = 65; int a = (t/2+1)*2; for(int i = 1;i<=t;i++){ for(int j = 1;j<=t-i;j++){ cout<<" "; } for(int j = 1;j<=i*2-1;j++){ cout<<char(n); n++; } cout<<endl; n = 65; } for(int i = t-1;i>=1;i--){ for(int j = 1;j<=t-i;j++){ cout<<" "; } for(int j = 1;j<=i*2-1;j++){ cout<<char(n); n++; } cout<<endl; n = 65; } return 0; }
3.两个等腰直角三角形拼成的图形
#include <iostream> using namespace std; int main() { int t; cin>>t; int n; for(int i = t;i>=1;i--){ n = 65; for(int j = 1;j<=t-i;j++){ cout<<" "; } for(int j = 1;j<=t;j++){ if(j==i){ cout<<"|"; n++; continue; } cout<<char(n); n++; } cout<<endl; } return 0; }
标签:std,字符,int,namespace,cin,65,main From: https://www.cnblogs.com/wangyihang-xh/p/18076152