Skip to content

Commit f37243a

Browse files
Add files via upload
1 parent 992582f commit f37243a

File tree

3 files changed

+82
-0
lines changed

3 files changed

+82
-0
lines changed

Patterns/Pattern7.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
}

Patterns/Pattern8.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
}

Patterns/Pattern9.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
}

0 commit comments

Comments
 (0)