Skip to content

Commit

Permalink
Merge pull request srbcheema1#43 from geekychaser/master
Browse files Browse the repository at this point in the history
Some patterns algo added. srbcheema1#4
  • Loading branch information
srbcheema1 authored Oct 1, 2017
2 parents 59f4610 + 5944fc7 commit 3b1e177
Show file tree
Hide file tree
Showing 6 changed files with 182 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Patterns/pattern1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <iostream>
using namespace std;

int main(){

int n;
cin >> n;

for( int i = 0; i < n; i++ ){
for( int j = 0; j < n; j++ ){
cout << "*";
}
cout << endl;
}
return 0;

}

/*
5
*****
*****
*****
*****
*/
28 changes: 28 additions & 0 deletions Patterns/pattern2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <iostream>
using namespace std;

int main(){

int n;
cin >> n;

for( int i = 0; i < n; i++ ){
for( int j = 0; j <= i; j++ ){
cout << "*";
}
cout << endl;
}

return 0;

}

/*
5
*
**
***
****
*****
*/
28 changes: 28 additions & 0 deletions Patterns/pattern3.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <iostream>
using namespace std;

int main(){

int n;
cin >> n;

for( int i = n; i > 0; i-- ){
for( int j = 0; j < i; j++ ){
cout << "*";
}
cout << endl;
}

return 0;
}

/*
5
*****
****
***
**
*
*/
41 changes: 41 additions & 0 deletions Patterns/pattern4.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include <iostream>
using namespace std;

int main(){

int n;
cin >> n;

for( int i = 0; i < n; i++ ){
for( int j = 0; j <= i; j++ ){
cout << "*";
}
cout << endl;
}

for( int i = n-1; i > 0; i-- ){
for( int j = 0; j < i; j++ ){
cout << "*";
}
cout << endl;
}

return 0;

}

/*
5
*
**
***
****
*****
****
***
**
*
*/
29 changes: 29 additions & 0 deletions Patterns/pattern6.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <iostream>
using namespace std;

int main(){

int n;
cin >> n;

for( int i = 1; i <= n; i++ ){
for( int j = 1; j <= i; j++ ){
cout << i;
}
cout << endl;
}

return 0;
}

/*
5
1
22
333
4444
55555
*/
30 changes: 30 additions & 0 deletions Patterns/pattern7.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <iostream>
using namespace std;

int main(){
int n;
cin >> n;

int count = 1;
for( int i = 0; i < n; i++ ){
for( int j = 0; j <= i; j++ ){
cout << count << " ";
count++;
}
cout << endl;
}
return 0;

}

/*
5
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
*/

0 comments on commit 3b1e177

Please sign in to comment.