-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #196 from ritikgupta88/main
- Loading branch information
Showing
10 changed files
with
252 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
IOT/ritikgupta88_RitikGupta_2125csit1163_2/Patterns/Pattern10.cpp
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 argc, char **argv){ | ||
int n; | ||
cin >> n; | ||
for(int i=0;i<(n/2)+1;i++){ | ||
for(int j=0;j<n;j++){ | ||
if(i+j==n/2|| j==n/2+i) | ||
cout<<"*\t"; | ||
else | ||
cout<<"\t"; | ||
|
||
} | ||
cout<<endl; | ||
|
||
} | ||
|
||
for(int i=(n/2)-1;i>=0;i--){ | ||
for(int j=0;j<n;j++){ | ||
if(i+j==n/2|| j==n/2+i) | ||
cout<<"*\t"; | ||
else | ||
cout<<"\t"; | ||
|
||
} | ||
cout<<endl; | ||
|
||
} | ||
|
||
|
||
} |
19 changes: 19 additions & 0 deletions
19
IOT/ritikgupta88_RitikGupta_2125csit1163_2/Patterns/Pattern11.cpp
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 argc, char **argv){ | ||
int n,k=1; | ||
cin >> n; | ||
for(int i=0;i<n;i++){ | ||
for(int j=0;j<=i;j++){ | ||
if(i+j<=2*i){ | ||
cout<<k<<"\t"; | ||
k++; | ||
} | ||
} | ||
cout<<endl; | ||
} | ||
|
||
//write your code here | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
IOT/ritikgupta88_RitikGupta_2125csit1163_2/Patterns/Pattern12.cpp
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 fibo(int n); | ||
int main(int argc, char **argv){ | ||
int n,k=1; | ||
cin >> n; | ||
for(int i=0;i<n;i++){ | ||
for(int j=0;j<=i;j++){ | ||
if(i+j<=2*i){ | ||
cout<<fibo(k)<<"\t"; | ||
k++; | ||
} | ||
} | ||
cout<<endl; | ||
} | ||
} | ||
int fibo(int n){ | ||
if(n==1 ) | ||
return 0; | ||
if(n==2) | ||
return 1; | ||
|
||
else | ||
return(fibo(n-1)+fibo(n-2)); | ||
|
||
//write your code here | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
IOT/ritikgupta88_RitikGupta_2125csit1163_2/Patterns/Pattern13.cpp
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,23 @@ | ||
|
||
#include <iostream> | ||
using namespace std; | ||
|
||
int main(int argc, char **argv){ | ||
int n; | ||
cin >> n; | ||
int arr[n][n]; | ||
for(int i=0;i<n;i++){ | ||
for(int j=0;j<n;j++){ | ||
if(i==j || j==0){ | ||
arr[i][j]= 1 ; | ||
cout<<"1\t"; | ||
} | ||
else if(j>0 && j<i){ | ||
arr[i][j]=(arr[i-1][j-1] + arr[i-1][j]); | ||
cout<<arr[i][j]<<'\t'; | ||
} | ||
|
||
} | ||
cout<<endl; | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
IOT/ritikgupta88_RitikGupta_2125csit1163_2/Patterns/Pattern14.cpp
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,9 @@ | ||
#include<iostream> | ||
using namespace std; | ||
int main(int agrc, char** argv){ | ||
int n; | ||
cin >> n; | ||
for(int i=1;i<=10;i++){ | ||
cout<<n<<" * "<<i<<" = "<<n*i<<endl; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
IOT/ritikgupta88_RitikGupta_2125csit1163_2/Patterns/Pattern15.cpp
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,42 @@ | ||
#include <iostream> | ||
using namespace std; | ||
|
||
int main(int argc, char **argv){ | ||
int n,k=0; | ||
cin >> n; | ||
for(int i=0;i<(n/2)+1;i++){ | ||
for(int j=0;j<=n;j++){ | ||
if(i+j<n/2|| j>n/2+i) | ||
cout<<" "; | ||
else{ | ||
|
||
if(j>=n/2+1) | ||
k--; | ||
if(j<n/2+1) | ||
k++; | ||
cout<<k<<"\t"; | ||
} | ||
|
||
} | ||
cout<<endl; | ||
|
||
} | ||
for(int i=(n/2)-1;i>=0;i--){ | ||
k=k-2; | ||
for(int j=0;j<=n;j++){ | ||
if(i+j<n/2|| j>n/2+i) | ||
cout<<" "; | ||
else{ | ||
if(j>=n/2+1) | ||
k--; | ||
if(j<n/2+1) | ||
k++; | ||
cout<<k<<"\t"; | ||
} | ||
} | ||
cout<<endl; | ||
|
||
} | ||
|
||
|
||
} |
27 changes: 27 additions & 0 deletions
27
IOT/ritikgupta88_RitikGupta_2125csit1163_2/Patterns/Pattern16.cpp
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,27 @@ | ||
#include <iostream> | ||
using namespace std; | ||
int main(int argc, char**argv){ | ||
int n; | ||
cin >> n; | ||
int k=0; | ||
|
||
|
||
for(int i=0;i<n;i++){ | ||
for(int j=0;j<2*n-1;j++){ | ||
if(j>i && j<2*n-2-i) | ||
cout<<"\t"; | ||
else{ | ||
if(j<=i) | ||
k++; | ||
|
||
cout<<k<<"\t"; | ||
if(i+j>=2*n-2) | ||
k--; | ||
} | ||
|
||
} | ||
cout<<endl; | ||
|
||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
IOT/ritikgupta88_RitikGupta_2125csit1163_2/Patterns/Pattern17.cpp
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,29 @@ | ||
#include <iostream> | ||
using namespace std; | ||
int main(int agrc, char**argv){ | ||
int n; | ||
cin >> n; | ||
for(int i=0;i<n;i++){ | ||
for(int j=0;j<n;j++){ | ||
if(i<n/2){ | ||
if(j<=n/2+i&&j>=n/2) | ||
cout<<"*\t"; | ||
else | ||
cout<<"\t"; | ||
} | ||
if(i==n/2) | ||
cout<<"*\t"; | ||
if(i>n/2){ | ||
if(j<(n/2+n-i) && j>=n/2) | ||
cout<<"*\t"; | ||
else | ||
cout<<"\t"; | ||
} | ||
|
||
} | ||
cout<<endl; | ||
} | ||
|
||
//write your code here | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
IOT/ritikgupta88_RitikGupta_2125csit1163_2/Patterns/Pattern18.cpp
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,27 @@ | ||
#include <iostream> | ||
using namespace std; | ||
int main(int agrc, char**argv){ | ||
int n; | ||
cin >> n; | ||
for(int i=0;i<n;i++){ | ||
for(int j=0;j<n;j++){ | ||
if(i<n/2){ | ||
if(i==0) | ||
cout<<"*\t"; | ||
else if(i==j || i+j==n-1) | ||
cout<<"*\t"; | ||
else | ||
cout<<"\t"; | ||
} | ||
if(i>=n/2){ | ||
if(i>=j && j+i>=n-1) | ||
cout<<"*\t"; | ||
else | ||
cout<<"\t"; | ||
} | ||
} | ||
cout<<endl; | ||
} | ||
//write your code here | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
IOT/ritikgupta88_RitikGupta_2125csit1163_2/Patterns/Pattern9.cpp
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 argc, char **argv){ | ||
int n; | ||
cin >> n; | ||
for(int i=0;i<n;i++){ | ||
for(int j=0;j<n;j++){ | ||
if(i+j==n-1 || i==j) | ||
cout<<"* "; | ||
else | ||
cout<<" "; | ||
} | ||
cout<<endl; | ||
} | ||
} |