forked from fineanmol/Hacktoberfest2026
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgpattern
More file actions
35 lines (31 loc) · 625 Bytes
/
Copy pathgpattern
File metadata and controls
35 lines (31 loc) · 625 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
// C++ program to print the pattern G
#include <iostream>
using namespace std;
void pattern(int line)
{
int i, j;
for(i = 0; i < line; i++)
{
for(j = 0; j < line; j++)
{
if((j == 1 && i != 0 && i != line - 1) ||
((i == 0 || i == line - 1) && j > 1 &&
j < line - 2) || (i == ((line - 1) / 2) &&
j > 2 && j < line - 1) || (j == line - 2 &&
i != 0 && i >= ((line - 1) / 2) && i != line - 1))
printf("*");
else
printf( " ");
}
printf("\n");
}
}
// Driver code
int main()
{
int line = 7;
pattern(line);
return 0;
}
// This code is contributed
// by vt_m.