Skip to content

Commit

Permalink
Merge pull request #196 from ritikgupta88/main
Browse files Browse the repository at this point in the history
  • Loading branch information
AnjumanHasan authored Oct 11, 2022
2 parents 0cf0c35 + 33ff7eb commit 6dadb0f
Show file tree
Hide file tree
Showing 10 changed files with 252 additions and 0 deletions.
32 changes: 32 additions & 0 deletions IOT/ritikgupta88_RitikGupta_2125csit1163_2/Patterns/Pattern10.cpp
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 IOT/ritikgupta88_RitikGupta_2125csit1163_2/Patterns/Pattern11.cpp
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 IOT/ritikgupta88_RitikGupta_2125csit1163_2/Patterns/Pattern12.cpp
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 IOT/ritikgupta88_RitikGupta_2125csit1163_2/Patterns/Pattern13.cpp
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;
}
}
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 IOT/ritikgupta88_RitikGupta_2125csit1163_2/Patterns/Pattern15.cpp
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 IOT/ritikgupta88_RitikGupta_2125csit1163_2/Patterns/Pattern16.cpp
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 IOT/ritikgupta88_RitikGupta_2125csit1163_2/Patterns/Pattern17.cpp
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 IOT/ritikgupta88_RitikGupta_2125csit1163_2/Patterns/Pattern18.cpp
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 IOT/ritikgupta88_RitikGupta_2125csit1163_2/Patterns/Pattern9.cpp
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;
}
}

0 comments on commit 6dadb0f

Please sign in to comment.