mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-11-30 07:55:31 +08:00
document stairs print
This commit is contained in:
@@ -1,31 +1,35 @@
|
|||||||
/*
|
/**
|
||||||
This program is use to print the following pattern
|
* @file
|
||||||
**
|
@brief This program is use to print the following pattern<pre>
|
||||||
**
|
\*\*
|
||||||
****
|
\*\*
|
||||||
****
|
\*\*\*\*
|
||||||
******
|
\*\*\*\*
|
||||||
******
|
\*\*\*\*\*\*
|
||||||
********
|
\*\*\*\*\*\*
|
||||||
********
|
\*\*\*\*\*\*\*\*
|
||||||
|
********</pre>
|
||||||
where number of pairs line is given by user
|
where number of pairs line is given by user
|
||||||
*/
|
*/
|
||||||
#include<iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
/** main function */
|
||||||
int main() {
|
int main() {
|
||||||
int l, st = 2, x, r, z, n, sp;
|
int l, st = 2, x, r, z, n, sp;
|
||||||
std::cout << "enter Index ";
|
std::cout << "enter Index ";
|
||||||
std::cin >> x;
|
std::cin >> x;
|
||||||
z = x;
|
z = x;
|
||||||
for (r = 1; r <= x; r++) {
|
for (r = 1; r <= x; r++) {
|
||||||
z = z - 1;
|
z = z - 1;
|
||||||
for (n = 1; n <= 2; n++) {
|
for (n = 1; n <= 2; n++) {
|
||||||
for (sp = 1; sp <= z; sp++) {
|
for (sp = 1; sp <= z; sp++) {
|
||||||
std::cout << " ";
|
std::cout << " ";
|
||||||
|
}
|
||||||
|
for (l = 1; l <= st; l++) {
|
||||||
|
std::cout << "*";
|
||||||
|
}
|
||||||
|
std::cout << std::endl;
|
||||||
|
}
|
||||||
|
st = st + 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (l = 1; l <= st; l++) {
|
|
||||||
std::cout << "*";
|
|
||||||
}
|
|
||||||
std::cout <<"\n";
|
|
||||||
}
|
|
||||||
st = st + 2;
|
|
||||||
}}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user