File tree Expand file tree Collapse file tree 3 files changed +82
-0
lines changed Expand file tree Collapse file tree 3 files changed +82
-0
lines changed Original file line number Diff line number Diff line change 1+ #include < bits/stdc++.h>
2+ using namespace std ;
3+
4+ void pattern7 (int n){
5+ for (int i = 0 ; i < n; i++){
6+ for (int j = 0 ; j < n - i - 1 ; j++){
7+ cout << " " ;
8+ }
9+ for (int j = 0 ; j < 2 *i + 1 ; j++){
10+ cout << " *" ;
11+ }
12+ for (int j = 0 ; j < n - i - 1 ; j++){
13+ cout << " " ;
14+ }
15+ cout << endl;
16+ }
17+ }
18+
19+ int main (){
20+ pattern7 (5 );
21+ return 0 ;
22+ }
Original file line number Diff line number Diff line change 1+ #include < bits/stdc++.h>
2+ using namespace std ;
3+
4+ void pattern8 (int n){
5+ for (int i = 1 ; i <= n; i++){
6+ for (int j = 1 ; j <= i; j++){
7+ cout << " " ;
8+ }
9+ for (int j = 1 ; j <= 2 *n - 2 *i + 1 ; j++){
10+ cout << " *" ;
11+ }
12+ for (int j = 1 ; j <= i; j++){
13+ cout << " " ;
14+ }
15+ cout << endl;
16+ }
17+ }
18+
19+ int main (){
20+ pattern8 (5 );
21+ return 0 ;
22+ }
Original file line number Diff line number Diff line change 1+ #include < bits/stdc++.h>
2+ using namespace std ;
3+
4+ void pattern (int n){
5+ for (int i = 0 ; i < n; i++){
6+ for (int j = 0 ; j < n - i - 1 ; j++){
7+ cout << " " ;
8+ }
9+ for (int j = 0 ; j < 2 *i + 1 ; j++){
10+ cout << " *" ;
11+ }
12+ for (int j = 0 ; j < n - i - 1 ; j++){
13+ cout << " " ;
14+ }
15+ cout << endl;
16+
17+ }
18+ }
19+
20+ void lowerpattern (int n){
21+ for (int i = 1 ; i <= n; i++){
22+ for (int j = 1 ; j < i; j++){
23+ cout << " " ;
24+ }
25+ for (int j = 1 ; j <= 2 *n - 2 *i + 1 ; j++){
26+ cout << " *" ;
27+ }
28+ for (int j = 1 ; j < i; j++){
29+ cout << " " ;
30+ }
31+ cout << endl;
32+ }
33+ }
34+
35+ int main (){
36+ pattern (5 );
37+ lowerpattern (5 );
38+ }
You can’t perform that action at this time.
0 commit comments