forked from shivprime94/Data-Structure-Algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpattern.cpp
More file actions
43 lines (39 loc) · 658 Bytes
/
pattern.cpp
File metadata and controls
43 lines (39 loc) · 658 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include<iostream>
using namespace std;
int main() {
int n;
cout<<"enter a no: ";
cin>>n;
int n1=(n+1)/2;
int i=1;
while(i<=n1){
int k=1;
while(k<=n1-i){
cout<<" ";
k++;
}
int j=1;
while(j<=2*i-1){
cout<<"*";
j++;
}
cout<<endl;
i++;
}
int n2 = n/2;
i = n2;
while(i>=1){
int k=1;
while(k<=n1-i){
cout<<" ";
k++;
}
int j=1;
while(j<=2*i-1){
cout<<"*";
j++;
}
cout<<endl;
i--;
}
}