-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patharrowPattern.cpp
More file actions
43 lines (40 loc) · 797 Bytes
/
arrowPattern.cpp
File metadata and controls
43 lines (40 loc) · 797 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
#include<iostream>
using namespace std;
/* Read input as specified in the question.
* Print output as specified in the question.
Print the following pattern for the given number of rows.
Assume N is always odd.
Note : There is space after every star.
Pattern for N = 7
*
* *
* * *
* * * *
* * *
* *
*
*/
int main(){
int n;
cin >> n;
int space=0;
for(int i=0; i<n/2 +1; i++){
for(int j=0; j< i; j++){
cout << " ";
}
for(int j=0; j<i+1; j++){
cout << "* ";
}
cout << "\n";
}
for(int i=n/2; i>0; i--){
for(int j=1; j<i; j++){
cout << " ";
}
for(int j=0; j<i; j++){
cout << "* ";
}
cout << "\n";
}
return 0;
}