您的位置:首页 > 编程语言 > C语言/C++

C++中关于打印一些字符图形的循环代码

2009-03-07 12:26 344 查看
打印字符图形

int main()

{
for(int i=1;i<=10;++i)
{
for(int j=1;j<=10-i;++j)
cout<<" ";
for(char ch='A';ch<='A'+2*i-2;++ch)
cout<<ch;
cout<<"/n";
}
}
A
ABC
ABCDE
ABCDEFG
ABCDEFGHI
ABCDEFGHIJK
ABCDEFGHIJKLM
ABCDEFGHIJKLMNO
ABCDEFGHIJKLMNOPQ
ABCDEFGHIJKLMNOPQRS

int main(){
for(int i=1;i<=10;++i)
{
for(int j=1;j<=i;++j)
cout<<"M";
cout<<endl;
}
}
M
MM
MMM
MMMM
MMMMM
MMMMMM
MMMMMMM
MMMMMMMM
MMMMMMMMM
MMMMMMMMMM

int main(){
for(int i=1;i<=10;++i){
for(int j=1;j<=i-1;++j)
cout<<" ";
for(int k=1;k<=21-2*i;++k)
cout<<"M";
cout<<endl;
}
}
MMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMM
MMMMMMMMMMMMM
MMMMMMMMMMM
MMMMMMMMM
MMMMMMM
MMMMM
MMM
M
int main(){
for(int i=1;i<=10;++i)
{
for(int j=1;j<=10-i;++j)
cout<<" ";
for(int k=1;k<=2*i-1;++k)
cout<<"%";
cout<<"/n";
/*cout<<endl;*/
}
for(int a=1;a<=9;++a)
{
for(int b=1;b<=a;++b)
cout<<" ";
for(int c =1;c<=19-2*a;++c)
cout<<"%";
cout<<endl;
}
}
%
%%%
%%%%%
%%%%%%%
%%%%%%%%%
%%%%%%%%%%%
%%%%%%%%%%%%%
%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%
%%%%%%%%%%%%%
%%%%%%%%%%%
%%%%%%%%%
%%%%%%%
%%%%%
%%%
%
int main(){
for(int i=1;i<=10;++i){
for(int j=1;j<=10-i;++j)
cout<<" ";
for(int k=1;k<=i;++k)
cout<<"#";
cout<<" ";
for(int m=1;m<=i;++m)
cout<<"$";
}
cin.get();
}
# $
## $$
### $$$
#### $$$$
##### $$$$$
###### $$$$$$
####### $$$$$$$
######## $$$$$$$$
######### $$$$$$$$$
########## $$$$$$$$$$
int main()
{
for(int i=1;i<=9;++i){
for(int j=1;j<=i-1;++j)
cout<<" ";
for(int k=1;k<=10-i;++k)
cout<<"ST";
cout<<"S";
cout<<"/n";
//.cout<<endl;
}
cout<<" ";
cout<<"S";
}
STSTSTSTSTSTSTSTSTS
STSTSTSTSTSTSTSTS
STSTSTSTSTSTSTS
STSTSTSTSTSTS
STSTSTSTSTS
STSTSTSTS
STSTSTS
STSTS
STS
S
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: