-
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.
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.
- Loading branch information
1 parent
812cfdd
commit e689239
Showing
20 changed files
with
587 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern1.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,22 @@ | ||
#include <iostream> | ||
using namespace std; | ||
|
||
int main(int argc, char **argv){ | ||
int n; | ||
cin >> n; | ||
int i,j,k; | ||
for(i=0;i<n;i++) | ||
{ | ||
for(j=0;j<n;j++) | ||
{ | ||
if(j<=i) | ||
{ | ||
cout<<"*\t"; | ||
} | ||
|
||
|
||
} | ||
cout << endl; | ||
} | ||
|
||
} |
42 changes: 42 additions & 0 deletions
42
IOT/Nivedita-R_NiveditaRai_2125it1079_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,42 @@ | ||
#include <iostream> | ||
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"; | ||
} | ||
} | ||
|
||
|
||
|
||
|
16 changes: 16 additions & 0 deletions
16
IOT/Nivedita-R_NiveditaRai_2125it1079_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,16 @@ | ||
#include <iostream> | ||
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<<endl; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
IOT/Nivedita-R_NiveditaRai_2125it1079_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,27 @@ | ||
#include <iostream> | ||
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<n*n;i++) | ||
{ | ||
k=a+b; | ||
arr[i]=k; | ||
a=b; | ||
b=k; | ||
} | ||
for(i=0;i<n;i++) | ||
{ | ||
for(j=0;j<=i;j++){ | ||
{cout<<arr[l]<<"\t"; | ||
l++;} | ||
} | ||
cout<<"\n"; | ||
} | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
IOT/Nivedita-R_NiveditaRai_2125it1079_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,22 @@ | ||
#include <iostream> | ||
using namespace std; | ||
|
||
int main(int argc, char **argv){ | ||
int n; | ||
cin >> n; | ||
|
||
int i,j,k,l; | ||
for ( i=0; i <n ; i++) | ||
{ | ||
int id = 1; | ||
for ( j=0; j <= i; j++) | ||
{ | ||
cout<< id << "\t" ; | ||
int id1 = (id * (i - j)) / (j + 1); | ||
id = id1; | ||
|
||
} | ||
cout<<"\n"; | ||
} | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
IOT/Nivedita-R_NiveditaRai_2125it1079_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,12 @@ | ||
#include<iostream> | ||
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 << " = " <<i*n << endl; | ||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
IOT/Nivedita-R_NiveditaRai_2125it1079_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,39 @@ | ||
#include <iostream> | ||
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<<k<<"\t"; | ||
if(j <=st / 2) | ||
k++; | ||
else | ||
k--; | ||
} | ||
|
||
if ( i <= n / 2) | ||
{ sp--; | ||
st += 2; | ||
} | ||
else | ||
{ | ||
sp++; | ||
st -= 2; | ||
} | ||
cout<< endl; | ||
|
||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
IOT/Nivedita-R_NiveditaRai_2125it1079_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,41 @@ | ||
#include <iostream> | ||
|
||
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<<j<<"\t"; | ||
} | ||
for(k=n-1;k>=i;k--) | ||
{ | ||
cout<<"\t"; | ||
} | ||
for(k=n-2;k>=i;k--) | ||
{ | ||
cout<<"\t"; | ||
} | ||
for(m=i;m>=1;m--) | ||
{ | ||
if(i==n) | ||
{ | ||
cout<<m-1<<"\t"; | ||
if(m==2) | ||
m--; | ||
} | ||
else | ||
cout<<m<<"\t"; | ||
} | ||
cout<<"\n"; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
|
36 changes: 36 additions & 0 deletions
36
IOT/Nivedita-R_NiveditaRai_2125it1079_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,36 @@ | ||
#include <iostream> | ||
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"; | ||
} | ||
} | ||
|
36 changes: 36 additions & 0 deletions
36
IOT/Nivedita-R_NiveditaRai_2125it1079_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,36 @@ | ||
#include <iostream> | ||
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"; | ||
} |
64 changes: 64 additions & 0 deletions
64
IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern19.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,64 @@ | ||
#include <iostream> | ||
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<<endl; | ||
} | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
IOT/Nivedita-R_NiveditaRai_2125it1079_2/Patterns/Pattern2.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,22 @@ | ||
#include <iostream> | ||
using namespace std; | ||
|
||
int main(int argc, char **argv){ | ||
int n; | ||
cin >> n; | ||
int i,j,k; | ||
for(i=0;i<n;i++) | ||
{ | ||
for(j=n-1;j>=0;j--) | ||
{ | ||
if(j>=i) | ||
{ | ||
cout<<"*\t"; | ||
} | ||
|
||
|
||
} | ||
cout << endl; | ||
} | ||
|
||
} |
Oops, something went wrong.