-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
60 changed files
with
667 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include<iostream> | ||
using namespace std; | ||
int main(){ | ||
int n; | ||
cout<<"Enter no. of lines: "; | ||
cin>>n; | ||
for(int i=n+1;i>1;i--){ | ||
for(int j=1;j<=2*n+1;j++){ | ||
// int a=n-i+1; | ||
int b=j; | ||
if(b>n+1) b=(2*n+2)-j; | ||
if((i==b)|| (j==n+1)) cout<<"*"; | ||
else cout<<" "; | ||
} | ||
cout<<endl; | ||
} | ||
|
||
for(int i=1;i<=2*n+1;i++){ | ||
cout<<"*"; | ||
} | ||
cout<<endl; | ||
|
||
for(int i=2;i<=n+1;i++){ | ||
for(int j=1;j<=2*n+1;j++){ | ||
// int a=n-i+1; | ||
int b=j; | ||
if(b>n+1) b=(2*n+2)-j; | ||
if((i==b)|| (j==n+1)) cout<<"*"; | ||
else cout<<" "; | ||
} | ||
cout<<endl; | ||
} | ||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include<iostream> | ||
using namespace std; | ||
int main(){ | ||
int n; | ||
cout<<"Enter n: "; | ||
cin>>n; | ||
for(int i=n;i>=1;i--){ | ||
for(int j=1;j<2*n;j++){ | ||
int a=j; | ||
if(a>n){ | ||
a=2*n-j; | ||
} | ||
if(i==a) cout<<"*"; | ||
else cout<<" "; | ||
} | ||
cout<<endl; | ||
} | ||
|
||
for(int i=2;i<=n;i++){ | ||
for(int j=1;j<2*n;j++){ | ||
int a=j; | ||
if(a>n){ | ||
a=2*n-j; | ||
} | ||
if(i==a) cout<<"*"; | ||
else cout<<" "; | ||
} | ||
cout<<endl; | ||
} | ||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include<iostream> | ||
using namespace std; | ||
int main(){ | ||
int n; | ||
cout<<"Enter no. of lines: "; | ||
cin>>n; | ||
for(int i=1;i<=n;i++){ | ||
for(int j=1;j<2*n;j++){ | ||
int a=n-i+1; | ||
int b=j; | ||
if(b>n) b=2*n-j; | ||
if(a==b) cout<<i; | ||
else cout<<" "; | ||
} | ||
cout<<endl; | ||
} | ||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#include<iostream> | ||
using namespace std; | ||
int main(){ | ||
int n; | ||
cout<<"Enter n: "; | ||
cin>>n; | ||
int a = n+1; | ||
for(int i=1;i<n;i++){ | ||
for(int j=1;j<=i;j++){ | ||
cout<<"*"; | ||
} | ||
|
||
for(int j=1;j<=a;j++){ | ||
cout<<" "; | ||
} | ||
a-=2; | ||
|
||
for(int j=1;j<=i;j++){ | ||
cout<<"*"; | ||
} | ||
|
||
cout<<endl; | ||
} | ||
|
||
for(int i=1;i<=n/2;i++){ | ||
for(int j=1;j<2*n;j++){ | ||
cout<<"*"; | ||
} | ||
cout<<endl; | ||
} | ||
|
||
int b=1; | ||
for(int i=1;i<n;i++){ | ||
for(int j=1;j<=n-i;j++){ | ||
cout<<"*"; | ||
} | ||
|
||
for(int j=1;j<=b;j++){ | ||
cout<<" "; | ||
} | ||
b+=2; | ||
|
||
for(int j=1;j<=n-i;j++){ | ||
cout<<"*"; | ||
} | ||
cout<<endl; | ||
} | ||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include<iostream> | ||
using namespace std; | ||
int main(){ | ||
int n; | ||
cout<<"Enter row: "; | ||
cin>>n; | ||
for(int i=1;i<2*n;i++) { | ||
cout<<(char)('A'+i-1); | ||
} | ||
cout<<endl; | ||
for(int i=1;i<n;i++){ | ||
int a=65; | ||
for(int j=1;j<=n-i;j++){ | ||
cout<<(char)a; | ||
a++; | ||
} | ||
for(int j=1;j<=2*i-1;j++){ | ||
cout<<" "; | ||
a++; | ||
} | ||
for(int j=1;j<=n-i;j++){ | ||
cout<<(char)a; | ||
a++; | ||
} | ||
cout<<endl; | ||
} | ||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include<iostream> | ||
using namespace std; | ||
int main (){ | ||
int i,j,n; | ||
cout<<"Enter the number : "; | ||
cin>>n; | ||
for(i=1;i<=n;i++){ | ||
for(j=1;j<=n;j++){ | ||
cout<<(char)(j+64)<<" "; | ||
} | ||
cout<<endl; | ||
} | ||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include<iostream> | ||
using namespace std; | ||
int main (){ | ||
int i,j,n; | ||
cout<<"Enter the number of rows: "; | ||
cin>>n; | ||
int a=1; | ||
|
||
for(i=1;i<n+1;i++){ | ||
for(j=1;j<=i;j++){ | ||
if((i+j)%2==0) cout<<1; | ||
else cout<<0; | ||
} | ||
cout<<endl; | ||
} | ||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include<iostream> | ||
using namespace std; | ||
int main (){ | ||
int i,j,n; | ||
cout<<"Enter the number of rows: "; | ||
cin>>n; | ||
int a=1; | ||
for(i=1;i<n+1;i++){ | ||
for(j=1;j<=i;j++){ | ||
cout<<a<<" "; | ||
a+=1; | ||
} | ||
cout<<endl; | ||
} | ||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include<iostream> | ||
using namespace std; | ||
int main(){ | ||
int n; | ||
cout<<"Enter n: "; | ||
cin>>n; | ||
for(int i=1;i<=n;i++){ | ||
if(i%2==1){ | ||
for(int j=1;j<=i;j++){ | ||
cout<<j<<" "; | ||
} | ||
} | ||
|
||
else{ | ||
int a=65; | ||
for(int j=1;j<=i;j++){ | ||
cout<<(char)a<<" "; | ||
a++; | ||
} | ||
} | ||
cout<<endl; | ||
} | ||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include<iostream> | ||
using namespace std; | ||
int main(){ | ||
int n; | ||
cout<<"Enter the no. of rows: "; | ||
cin>>n; | ||
|
||
int m = n-1; | ||
for(int i=1;i<2*n;i++){ | ||
cout<<i; | ||
} | ||
cout<<endl; | ||
for(int a=1;a<=m;a++){ | ||
int s=1; | ||
for(int i=1;i<=m+1-a;i++){ | ||
cout<<s; | ||
s++; | ||
} | ||
|
||
for(int j=1;j<2*a;j++){ | ||
cout<<" "; | ||
s++; | ||
} | ||
|
||
for(int i=1;i<=m+1-a;i++){ | ||
cout<<s; | ||
s++; | ||
} | ||
cout<<endl; | ||
} | ||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include<iostream> | ||
using namespace std; | ||
int main(){ | ||
int r; | ||
cout<<"Enter the number of rows: "; | ||
cin>>r; | ||
for(int i=1;i<=r;i++){ | ||
for(int j=1;j<=r-i;j++){ | ||
cout<<" "; | ||
} | ||
for(int k=1;k<=i;k++){ | ||
cout<<k; | ||
} | ||
for(int q=i-1;q>=1;q--){ | ||
cout<<q; | ||
} | ||
cout<<endl; | ||
} | ||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include<iostream> | ||
using namespace std; | ||
int main(){ | ||
int n; | ||
cout<<"Enter the no. of rows: "; | ||
cin>>n; | ||
for(int i=1;i<2*n;i++){ | ||
if(i>n){ | ||
int a=(2*n)-i; | ||
cout<<a; | ||
} | ||
else cout<<i; | ||
|
||
} | ||
cout<<endl; | ||
for(int a=1;a<n;a++){ | ||
for(int i=1;i<=n-a;i++){ | ||
cout<<i; | ||
} | ||
|
||
for(int j=1;j<2*a;j++){ | ||
cout<<" "; | ||
} | ||
|
||
for(int i=n-a;i>=1;i--){ | ||
cout<<i; | ||
} | ||
cout<<endl; | ||
} | ||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include<iostream> | ||
using namespace std; | ||
int main(){ | ||
int n; | ||
cout<<"Enter n: "; | ||
cin>>n; | ||
for(int i=1;i<2*n;i++){ | ||
for(int j=1;j<2*n;j++){ | ||
int a=i; | ||
int b=j; | ||
if (i>n) a=2*n-i; | ||
if(b>n) b=2*n-j; | ||
int x = min(a,b); | ||
cout<<n-x+1<<" "; | ||
} | ||
cout<<endl; | ||
} | ||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include<iostream> | ||
using namespace std; | ||
int main (){ | ||
int i,j,n; | ||
cout<<"Enter the number : "; | ||
cin>>n; | ||
for(i=1;i<=n;i++){ | ||
for(j=1;j<=n;j++){ | ||
cout<<j<<" "; | ||
} | ||
cout<<endl; | ||
} | ||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include<iostream> | ||
using namespace std; | ||
int main(){ | ||
int n; | ||
cout<<"Enter n: "; | ||
cin>>n; | ||
for(int i=1;i<2*n;i++){ | ||
for(int j=1;j<2*n;j++){ | ||
int a=i; | ||
int b=j; | ||
if(a>n) a=2*n-i; | ||
if(b>n) b=2*n-j; | ||
cout<<min(a,b); | ||
} | ||
cout<<endl; | ||
} | ||
return 0; | ||
} |
Binary file not shown.
Oops, something went wrong.