Skip to content

Added more files #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 147 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,153 @@ Doing pattern problem question in C and C++
2 3
4 5 6
7 8 9 10


20.

*******
* *
* *
* *
* *
* *
*******

21.

***** *****
**** ****
*** ***
** **
* *
* *
** **
*** ***
**** ****
***** *****

22.

*
* *
* *
* *
* *
* *
* *
* *
* *
*

23.

1
2*2
3*3*3
4*4*4*4
5*5*5*5*5
6*6*6*6*6*6
7*7*7*7*7*7*7

24.

A
ABA
ABCBA
ABCDCBA
ABCDEDCBA
ABCDEFEDCBA
ABCDEFGFEDCBA

25.

1
12
1 3
1 4
1 5
1 6
1234567

26.

1234567
2 7
3 7
4 7
5 7
67
7

27.

********1********
*******2*2*******
******3*3*3******
*****4*4*4*4*****
****5*5*5*5*5****
***6*6*6*6*6*6***
**7*7*7*7*7*7*7**
*8*8*8*8*8*8*8*8*
9*9*9*9*9*9*9*9*9

28.

1
121
12321
1234321
123454321
12345654321
1234567654321

29.

1
2*3
4*5*6
7*8*9*10
11*12*13*14*15
11*12*13*14*15
7*8*9*10
4*5*6
2*3
1


30.

1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
1 6 15 20 15 6 1

31.

1
123
12345
1234521
123454321
12345
123
1

32.

* *
** **
*** ***
**** ****
**********
**********
**** ****
*** ***
** **
* *



Expand Down
19 changes: 19 additions & 0 deletions pattern20.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include<iostream>
using namespace std;

int main(){
int n;
cin>>n;
for(int i =0;i<n;i++){
for(int j=0;j<n;j++){
if(i==0 || i== n-1 || j == 0 || j== n-1){
cout<< "*" ;
}
else{
cout<<" ";
}
}
cout<<endl;
}
return 0;
}
33 changes: 33 additions & 0 deletions pattern21.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include<iostream>
using namespace std;

int main(){
int n;
cin>>n;
for(int i =0;i<n;i++){
for(int j=0;j<n-i;j++){
cout<< "*" ;
}
for(int j =0;j<((2*i)+1);j++){
cout<<" ";
}
for(int k =0;k<n-i;k++){
cout<<"*";
}
cout<<endl;
}

for(int i =0;i<n;i++){
for(int j=0;j<i+1;j++){
cout<< "*" ;
}
for(int j =0;j<((2*n)-(2*i)-1);j++){
cout<<" ";
}
for(int k =0;k<i+1;k++){
cout<<"*";
}
cout<<endl;
}
return 0;
}
39 changes: 39 additions & 0 deletions pattern22.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include<iostream>
using namespace std;

int main(){
int n;
cin>>n;
// upper
for(int i =0;i<n;i++){
for(int j=0;j<n-i-1;j++){
cout<< " " ;
}
for(int k=0;k<i+1;k++){
if(k==0||k==(i+1)-1){
cout<<"* ";
}
else{
cout<<" ";
}
}

cout<<endl;
}

// lower

for(int i =0;i<n;i++){
for(int j=0;j<i;j++){
cout<< " " ;
}
for(int k=0;k<(2*n)-(2*i)-1;k++){
if(k==0||k==((2*n)-(2*i)-1)-1)
cout<<"* ";
else
cout<<" ";
}
cout<<endl;
}
return 0;
}
18 changes: 18 additions & 0 deletions pattern23.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include<iostream>
using namespace std;

int main(){
int n;
cin>>n;
for(int i =0;i<n;i++){
for(int j=0;j<(2*i)+1;j++){
if(j%2==1)
cout<< "*" ;
else
cout<<i+1;

}
cout<<endl;
}
return 0;
}
18 changes: 18 additions & 0 deletions pattern24.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
for(int i =0;i<n;i++){
char ch;
for(int j=0;j<i+1;j++){
ch = j+1 +'A'-1;
cout<<ch ;
}
for(char t=ch;t>'A';){
t=t-1;
cout<<t;
}
cout<<endl;
}
}
18 changes: 18 additions & 0 deletions pattern25.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
for(int i =0;i<n;i++){
for(int j=0;j<=i;j++){
if(j==0||j==i||i==n-1) {
cout<< j+1 ;
}
else{
cout<<" ";
}
}
cout<<endl;
}
return 0;
}
16 changes: 16 additions & 0 deletions pattern26.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
for(int i =0;i<n;i++){
for(int j=i+1;j<=n;j++){
if(i==0||j==n||j==i+1)
cout<< j ;
else
cout<<" ";
}
cout<<endl;
}
return 0;
}
23 changes: 23 additions & 0 deletions pattern27.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
for(int i=0;i<n;i++){
int start_num_index = 8-i;
int num = i+1;
int count_num =num;
for(int j=0;j<17;j++){
if(j==start_num_index && count_num > 0){
cout<<num;
start_num_index+=2;
count_num--;
}
else{
cout<<"*";
}
}
cout<<endl;
}
return 0;
}
31 changes: 31 additions & 0 deletions pattern28.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
int k=n;
for(int i=0;i<n;i++){
int c=1;
for(int j=0;j<k;j++){
if(j<n-i-1){
cout<<" ";
}
else if (j<=n-1){
cout<<c;
c++;
}
else if(j==n){
c=c-2;
cout<<c;
c--;
}
else{
cout<<c;
c--;
}
}
k++;
cout<<endl;
}
return 0;
}
Loading