From e689239eef56e61e7016abb27898738509a29634 Mon Sep 17 00:00:00 2001 From: Nivedita-R <114609783+Nivedita-R@users.noreply.github.com> Date: Mon, 17 Oct 2022 22:00:42 +0530 Subject: [PATCH] Completed Module Patterns (#208) [HF] * Create Hello.txt Create Hello.txt * module1 my first module of programs * more from getting started some ques from getting started * Module Patterns completed module patterns. --- .../Patterns/Pattern1.cpp | 22 +++++++ .../Patterns/Pattern10.cpp | 42 ++++++++++++ .../Patterns/Pattern11.cpp | 16 +++++ .../Patterns/Pattern12.cpp | 27 ++++++++ .../Patterns/Pattern13.cpp | 22 +++++++ .../Patterns/Pattern14.cpp | 12 ++++ .../Patterns/Pattern15.cpp | 39 +++++++++++ .../Patterns/Pattern16.cpp | 41 ++++++++++++ .../Patterns/Pattern17.cpp | 36 +++++++++++ .../Patterns/Pattern18.cpp | 36 +++++++++++ .../Patterns/Pattern19.cpp | 64 +++++++++++++++++++ .../Patterns/Pattern2.cpp | 22 +++++++ .../Patterns/Pattern20.cpp | 27 ++++++++ .../Patterns/Pattern3.cpp | 24 +++++++ .../Patterns/Pattern4.cpp | 24 +++++++ .../Patterns/Pattern5.cpp | 31 +++++++++ .../Patterns/Pattern6.cpp | 35 ++++++++++ .../Patterns/Pattern7.cpp | 22 +++++++ .../Patterns/Pattern8.cpp | 22 +++++++ .../Patterns/Pattern9.cpp | 23 +++++++ 20 files changed, 587 insertions(+) create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern1.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern10.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern11.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern12.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern13.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern14.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern15.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern16.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern17.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern18.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern19.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern2.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern20.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern3.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern4.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern5.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern6.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern7.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern8.cpp create mode 100644 IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern9.cpp diff --git a/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern1.cpp b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern1.cpp new file mode 100644 index 00000000..e674dac1 --- /dev/null +++ b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern1.cpp @@ -0,0 +1,22 @@ +#include +using namespace std; + +int main(int argc, char **argv){ + int n; + cin >> n; +int i,j,k; +for(i=0;i +using namespace std; +int main(int argc, char** argv){ + int n; + cin >> n; + int s1 = n / 2; + int s2 = -1; + + for (int i = 1; i <= n; i++) + { + for (int j = 1; j <= s1; j++) + { + cout << "\t"; + } + cout << "*\t"; + + for (int j = 1; j <= s2; j++) + { + cout << "\t"; + } + if ( i > 1 && i < n) + { + cout << "*\t"; + } + + if (i <= n / 2) + { + s1--; + s2 = s2 + 2; + } + else + { + s1++; + s2 = s2 - 2; + } + cout<<"\n"; + } + } + + + + \ No newline at end of file diff --git a/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern11.cpp b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern11.cpp new file mode 100644 index 00000000..e31115db --- /dev/null +++ b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern11.cpp @@ -0,0 +1,16 @@ +#include +using namespace std; + +int main(int argc, char **argv){ + int n,i,j,k=1; + cin >> n; + for(i=1;i<=n;i++) + { + for(j=1;j<=i;j++) + { + cout<< k<<"\t"; + k++; + } + cout< +using namespace std; + +int main(int argc, char **argv){ + int n,*arr; + cin >> n; + arr=(int*)malloc((n*n)*sizeof(int)); + int i,j,k,l=0; + int a=0,b=1; + arr[0]=0;arr[1]=1; + for(i=2;i +using namespace std; + +int main(int argc, char **argv){ + int n; + cin >> n; + + int i,j,k,l; + for ( i=0; i +using namespace std; +int main(int agrc, char** argv){ + int n; + cin >> n; + int i,j,k; + for(i=1;i<=10;i++) + { + cout << n << " * " << i << " = " < +using namespace std; + +int main(int argc, char **argv){ + int n; + cin >> n; +int i,j,k; + int sp = n / 2, st = 1; + for (int i = 1; i <= n; i++) + { if(i <= n/2) + k=i; + else + k=n-i+1; + for (int j = 1; j <= sp; j++) + { + cout<<"\t"; + } + for (int j = 1; j <= st; j++) + { + cout< + +using namespace std; + +int main() +{ + + int i,j,k,l,m,n; + cin >> n; + for(i=1;i<=n;i++) + { + for(j=1;j<=i;j++) + { + cout<=i;k--) + { + cout<<"\t"; + } + for(k=n-2;k>=i;k--) + { + cout<<"\t"; + } + for(m=i;m>=1;m--) + { + if(i==n) + { + cout< +using namespace std; + +int main(int argc, char **argv){ + int n; + cin >> n; +int i,j,k; + int sp = n / 2, st = 1; + for (int i = 1; i <= n; i++) + { + for (int j = 1; j <= sp ; j++) + { + if ( i == n / 2 + 1) + { + cout<<"*\t"; + } + else + { + cout<<"\t"; + } + } + for (int j = 1 ; j <= st; j++) + { + cout<<"*\t"; + } + if ( i <= n / 2) + { + st++; + } + else { + st--; + } + cout<<"\n"; + } + } + diff --git a/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern18.cpp b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern18.cpp new file mode 100644 index 00000000..507e555e --- /dev/null +++ b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern18.cpp @@ -0,0 +1,36 @@ +#include +using namespace std; +int main(int agrc, char**argv){ + int n; + cin >> n; +int i,j,k,l; + int sp=0,st=n; + for(i=1;i<=n;i++) + { + for(j=1;j<=sp;j++) + cout<<"\t"; + for (int j = 1; j <= st; j++) + { + if ( i > 1 && i <= n / 2 && j > 1 && j < st) + { + cout<<"\t"; + } + else + { + cout<<"*\t"; + } + } + cout<<"\n"; + + if(i<=n/2) + { + sp=sp+1; + st=st-2; + } + else + { + sp=sp-1; + st=st+2; + }} + cout<<"\n"; +} \ No newline at end of file diff --git a/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern19.cpp b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern19.cpp new file mode 100644 index 00000000..9d83df49 --- /dev/null +++ b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern19.cpp @@ -0,0 +1,64 @@ +#include +using namespace std; +int main(int argc, char** argv){ + int n; + cin >> n; + +int i,j,k,l; +for(i = 1;i <= n; i++) +{ + for (int j = 1 ; j <= n; j++) + { + if ( i == 1) + { + if ( j == n || j <= (n +1) / 2) + { + cout<<"*\t"; + } + else + { + cout<<"\t"; + } + } + else if (i <= n / 2) + { + if ( j == n || j == (n + 1)/ 2 ) + { + cout<<"*\t"; + } + else + { + cout<<"\t"; + } + } + else if ( i == (n + 1) / 2 ) + { + cout<<"*\t"; + } + else if (i < n) + { + if (j == 1 || j == (n +1) /2) + { + cout<<"*\t"; + } + else + { + cout<<"\t"; + } + } + else + { + if (j == 1 || j >= (n +1) / 2) + { + cout<<"*\t"; + } + else + { + cout<<"\t"; + } + } + } + cout< +using namespace std; + +int main(int argc, char **argv){ + int n; + cin >> n; +int i,j,k; +for(i=0;i=0;j--) + { + if(j>=i) + { + cout<<"*\t"; + } + + + } + cout << endl; +} + +} \ No newline at end of file diff --git a/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern20.cpp b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern20.cpp new file mode 100644 index 00000000..5c7104e1 --- /dev/null +++ b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern20.cpp @@ -0,0 +1,27 @@ +#include +using namespace std; +int main(int argc, char** argv){ + int n; + cin >> n; + for (int i = 1; i <= n; i++) + { + for (int j = 1; j <= n; j++) + { + if ( j == 1 || j == n) + { + cout<<"*\t"; + } + else if (i > n / 2 && (i == j || i + j == n + 1)) + { + cout<<"*\t"; + } + else + { + cout<<"\t"; + } + } + cout<< endl; + } + } + + \ No newline at end of file diff --git a/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern3.cpp b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern3.cpp new file mode 100644 index 00000000..f234e640 --- /dev/null +++ b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern3.cpp @@ -0,0 +1,24 @@ +#include +using namespace std; + +int main(int argc, char **argv){ + int n; + cin >> n; +int i,j,k; +for(i=0;i=0;j--) + { + if(j>i) + { + cout<<"\t"; + } + else + cout <<"*\t"; + + + } + cout << endl; +} + +} \ No newline at end of file diff --git a/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern4.cpp b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern4.cpp new file mode 100644 index 00000000..8f423c29 --- /dev/null +++ b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern4.cpp @@ -0,0 +1,24 @@ +#include +using namespace std; + +int main(int argc, char **argv){ + int n; + cin >> n; +int i,j,k; +for(i=0;i=i) + { + cout<<"*\t"; + } + else + cout <<"\t"; + + + } + cout << endl; +} + +} \ No newline at end of file diff --git a/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern5.cpp b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern5.cpp new file mode 100644 index 00000000..d5e2f315 --- /dev/null +++ b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern5.cpp @@ -0,0 +1,31 @@ +#include +using namespace std; + +int main(int argc, char **argv){ + int n; + cin >> n; +int i,j,k; + int sp = n / 2, st = 1; + for (int i = 1; i <= n; i++) + { + for (int j = 1; j <= sp; j++) + { + cout<<"\t"; + } + for (int j = 1; j <= st; j++) + { + cout<<"*\t"; + } + if ( i <= n / 2) + { sp--; + st += 2; + } + else + { + sp++; + st -= 2; + } + cout<< endl; + + } +} \ No newline at end of file diff --git a/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern6.cpp b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern6.cpp new file mode 100644 index 00000000..695dcca7 --- /dev/null +++ b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern6.cpp @@ -0,0 +1,35 @@ +#include +using namespace std; + +int main(int argc, char **argv){ + int n; + cin >> n; +int i,j,k; + int sp = (n+1)/ 2, st = 1; + for (int i = 1; i <= n; i++) + { + for (int j = 1; j <= sp; j++) + { + cout<<"*\t"; + } + for (int j = 1; j <= st; j++) + { + cout<<"\t"; + } + for (int j = 1; j <= sp; j++) + { + cout<<"*\t"; + } + if ( i <= n / 2) + { sp--; + st += 2; + } + else + { + sp++; + st -= 2; + } + cout<< endl; + + } +} \ No newline at end of file diff --git a/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern7.cpp b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern7.cpp new file mode 100644 index 00000000..3266a4ac --- /dev/null +++ b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern7.cpp @@ -0,0 +1,22 @@ +#include +using namespace std; + +int main(int argc, char **argv){ + int n; + cin >> n; +int i,j,k; +for(i=0;i +using namespace std; + +int main(int argc, char **argv){ + int n; + cin >> n; +int i,j,k; +for(i=0;i=0;j--) + { + if(j==i) + cout<<"*\t"; + else + cout << "\t"; + + + } + cout << "\n"; +} + +} \ No newline at end of file diff --git a/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern9.cpp b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern9.cpp new file mode 100644 index 00000000..7bcfc39d --- /dev/null +++ b/IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern9.cpp @@ -0,0 +1,23 @@ +#include +using namespace std; + +int main(int argc, char **argv){ + int n; + cin >> n; + int i,j,k; + k = n-1; +for(i=0;i