Skip to content

Commit 52370ab

Browse files
Num $ Star Patterns
1 parent 07c9287 commit 52370ab

File tree

8 files changed

+266
-0
lines changed

8 files changed

+266
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
int main()
5+
{
6+
int n,i,j,k=1;
7+
cin>>n;
8+
9+
for (i=1 ; i<=n ; i++)
10+
{
11+
for(j=1 ; j<=i ;j++)
12+
{
13+
cout<<k<<" ";
14+
k++;
15+
}
16+
cout<<endl;
17+
}
18+
19+
return 0;
20+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
int main()
5+
{
6+
int n,i,j,k=1;
7+
cin>>n;
8+
9+
for (i=1 ; i<=n ; i++)
10+
{
11+
for(j=1 ; j<=i ; j++)
12+
{
13+
cout<<"*"<<" ";
14+
}
15+
cout<<endl;
16+
}
17+
i=0;j=0;
18+
for(i=n-1 ; i>=1 ; i--)
19+
{
20+
for(j=1 ; j<=i ; j++)
21+
{
22+
cout<<"*"<<" ";
23+
}
24+
cout<<endl;
25+
}
26+
27+
28+
return 0;
29+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
int main()
5+
{
6+
int n,i,j,k=1;
7+
cin>>n;
8+
9+
for(i=1, k=0 ; i<=n ; i++, k=0)
10+
{
11+
for(j=1 ; j<=(n-i) ; j++)
12+
{
13+
cout<<" ";
14+
}
15+
while(k != (2*i)-1 )
16+
{
17+
cout<<"*";
18+
k++;
19+
}
20+
cout<<endl;
21+
}
22+
for(i=n-1 , k=0 ; i>=1 ; i--, k=0)
23+
{
24+
for(j=1 ; j<=(n-i) ; j++)
25+
{
26+
cout<<" ";
27+
}
28+
while(k != (2*i)-1 )
29+
{
30+
cout<<"*";
31+
k++;
32+
}
33+
cout<<endl;
34+
}
35+
36+
return 0;
37+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
int main()
5+
{
6+
int n,i,j,k;
7+
cin>>n;
8+
9+
for(i=1 ; i<=n ; i++)
10+
{
11+
for(j=1 ; j<=n ; j++)
12+
{
13+
if((i==1) || (i==n) || (j==1) || (j==n))
14+
cout<<"* ";
15+
else
16+
cout<<" ";
17+
}
18+
cout<<endl;
19+
}
20+
21+
// for(i=1 ; i<=n ; i++)
22+
// {
23+
// if(i==1 || i==n)
24+
// {
25+
// for(j=1 ; j<=n ; j++)
26+
// {
27+
// cout<<"*";
28+
// }
29+
// cout<<endl;
30+
// }
31+
// else
32+
// {
33+
// cout<<"*";
34+
// for(k=1 ; k<=n-2 ; k++)
35+
// cout<<" ";
36+
// cout<<"*"<<endl;
37+
// }
38+
// }
39+
return 0;
40+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
int main()
5+
{
6+
int n,i,j,k;
7+
cin>>n;
8+
9+
for(i=0 ; i<n ; i++)
10+
{
11+
k=i;
12+
while (k)
13+
{
14+
cout<<" ";
15+
k--;
16+
}
17+
for(j=0 ; j<n-i ; j++)
18+
{
19+
cout<<"* ";
20+
}
21+
cout<<endl;
22+
}
23+
24+
return 0;
25+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
int main()
5+
{
6+
int n,i,j,k;
7+
cin>>n;
8+
9+
for(i=1 ; i<=n ; i++)
10+
{
11+
// k=n-i;
12+
// while (k)
13+
// {
14+
// cout<<" ";
15+
// k--;
16+
// }
17+
// for(j=1 ; j<=i ; j++)
18+
// {
19+
// cout<<"* ";
20+
// }
21+
// cout<<endl;
22+
k=0;
23+
while (k != (n-i))
24+
{
25+
cout<<" ";
26+
k++;
27+
}
28+
for ( j = 1; j <= (2*i)-1 ; j++)
29+
{
30+
if((j%2)==0)
31+
cout<<" ";
32+
else
33+
cout<<"*";
34+
}
35+
cout<<endl;
36+
37+
}
38+
39+
return 0;
40+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
int main()
5+
{
6+
int n,i,j,k;
7+
cin>>n;
8+
9+
for(i=1 ; i<=n ; i++)
10+
{
11+
k=n-i;
12+
while (k)
13+
{
14+
cout<<" ";
15+
k--;
16+
}
17+
for(j=1 ; j<=i ; j++)
18+
{
19+
cout<<"* ";
20+
}
21+
cout<<endl;
22+
}
23+
24+
for(i=1 ; i<=n-1 ; i++)
25+
{
26+
k=i;
27+
while (k)
28+
{
29+
cout<<" ";
30+
k--;
31+
}
32+
for(j=1 ; j<=n-i ; j++)
33+
{
34+
cout<<"* ";
35+
}
36+
cout<<endl;
37+
}
38+
39+
return 0;
40+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
int main()
5+
{
6+
int i,j,k,n;
7+
cin>>n;
8+
9+
for (i = 0; i <= n/2 ; i++)
10+
{
11+
for(j=0 ; j<n ; j++)
12+
{
13+
if((j >= (n/2)-i) && (j <= (n/2)+i))
14+
cout<<" ";
15+
else
16+
cout<<"* ";
17+
}
18+
cout<<endl;
19+
}
20+
21+
for (i = 0; i < n/2 ; i++)
22+
{
23+
for(j=0 ; j<n ; j++)
24+
{
25+
if((j <= i) || (j >= (n-i-1)))
26+
cout<<"* ";
27+
else
28+
cout<<" ";
29+
}
30+
cout<<endl;
31+
}
32+
33+
34+
return 0;
35+
}

0 commit comments

Comments
 (0)