字符图画

三角

#include<iostream>
using namespace std;
int main(){
	int i,j,k;
	char ch;
	for(i=1;i<=10;i++){
		ch='A';
		for(j=1;j<=10-i;++j){
			cout<<" ";
		}
		for(k=1;k<=2*i-1;++k){
			cout<<ch;
			ch++;
		}
		cout<<endl;
	}
	return 0;
}

菱形

#include<iostream>
using namespace std;
int main(){
	int i,j,k;
	char ch;
	for(i=1;i<=10;i++){
		ch='A';
		for(j=1;j<=10-i;++j){
			cout<<" ";
		}
		for(k=1;k<=2*i-1;++k){
			cout<<ch;
			ch++;
		}
		cout<<endl;
	}
	for(i=9;i>=1;i--){
		ch='A';
		for(j=1;j<=10-i;++j){
			cout<<" ";
		}
		for(k=1;k<=2*i-1;++k){
			cout<<ch;
			ch++;
		}
		cout<<endl;
	}
	return 0;
}

平行四边形

#include<iostream>
using namespace std;
int main(){
	int i,j,k;
	char ch;
	for(i=10;i>=0;i--){
		ch='A';
		for(j=1;j<=10-i;++j){
			cout<<" ";
		}
		for(k=1;k<=10;++k){
			cout<<ch;
			if(k==11-j){
				cout<<'|';
			}
			ch++;
		}
		cout<<endl;
	}
	return 0;
}
posted @ 2024-03-15 20:11  王ys  阅读(6)  评论(0编辑  收藏  举报