TheAlgorithms-C-Plus-Plus/others/stairs_pattern.cpp

31 lines
477 B
C++
Raw Normal View History

2020-04-19 21:19:08 +08:00
/*
This program is use to print the following pattern
**
**
****
****
******
******
********
********
2020-04-19 23:09:06 +08:00
where number of pairs line is given by user */
#include<iostream>
int main() {
2020-04-19 22:53:48 +08:00
int l, st = 2, x, r, z, n, sp;
std::cout << "enter Index ";
std::cin >> x;
z = x;
2020-04-19 23:09:06 +08:00
for (r = 1; r <= x; r++) {
2020-04-19 22:53:48 +08:00
z = z - 1;
2020-04-19 23:09:06 +08:00
for (n = 1; n <= 2; n++) {
for (sp = 1; sp <= z; sp++) {
2020-04-19 22:53:48 +08:00
std::cout << " ";
2020-04-19 21:19:08 +08:00
}
2020-04-19 23:09:06 +08:00
for (l = 1; l <= st; l++) {
2020-04-19 22:53:48 +08:00
std::cout << "*";
}
std::cout <<"\n";
}
st = st + 2;
}}