mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-02-09 21:47:07 +08:00
Merge pull request #722 from faizanahamed1414/patch-1
Create stairs_pattern.cpp
This commit is contained in:
31
others/stairs_pattern.cpp
Normal file
31
others/stairs_pattern.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
This program is use to print the following pattern
|
||||
**
|
||||
**
|
||||
****
|
||||
****
|
||||
******
|
||||
******
|
||||
********
|
||||
********
|
||||
where number of pairs line is given by user
|
||||
*/
|
||||
#include<iostream>
|
||||
int main() {
|
||||
int l, st = 2, x, r, z, n, sp;
|
||||
std::cout << "enter Index ";
|
||||
std::cin >> x;
|
||||
z = x;
|
||||
for (r = 1; r <= x; r++) {
|
||||
z = z - 1;
|
||||
for (n = 1; n <= 2; n++) {
|
||||
for (sp = 1; sp <= z; sp++) {
|
||||
std::cout << " ";
|
||||
}
|
||||
for (l = 1; l <= st; l++) {
|
||||
std::cout << "*";
|
||||
}
|
||||
std::cout <<"\n";
|
||||
}
|
||||
st = st + 2;
|
||||
}}
|
||||
Reference in New Issue
Block a user