码迷,mamicode.com
首页 > 编程语言 > 详细

C++ Program to Print Alphabet Triangle

时间:2019-05-18 11:15:14      阅读:132      评论:0      收藏:0      [点我收藏+]

标签:tps   clu   c++   rom   ram   \n   ++   pac   ber   

There are different triangles that can be printed.

Triangles can be generated by alphabets or numbers.

In this C++ program, we are going to print alphabet triangles.

Let‘s see the C++ example to print alphabet triangle.

 

#include<iostream>

using namespace std;


int main() {
char ch=‘Z‘;
int i, j,k,m;
for (i=1;i<=5;i++) {

for(j=5;j>=i;j--)
cout<<" ";
for (k=1;k<=i;k++)
cout<<ch++;
ch--;
for(m=1;m<i;m++)
cout<<--ch;
cout<<"\n";
ch=‘A‘;
}
return 0;
}

 

 

xfer from  https://www.javatpoint.com/cpp-program-to-print-alphabet-triangle

C++ Program to Print Alphabet Triangle

标签:tps   clu   c++   rom   ram   \n   ++   pac   ber   

原文地址:https://www.cnblogs.com/poission/p/10884972.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!