forked from shivaylamba/Hacktoberfest
-
Notifications
You must be signed in to change notification settings - Fork 0
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 shivaylamba#569 from Srijan7777/master
Added Algorithms
- Loading branch information
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
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,20 @@ | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
string MaxString(string str) | ||
{ | ||
// loop to find the max leicographic | ||
// substring in the substring array | ||
string mx = ""; | ||
for (int i = 0; i < str.length(); ++i) | ||
mx = max(mx, str.substr(i)); | ||
|
||
return mx; | ||
} | ||
|
||
int main() | ||
{ | ||
string str = "ababaa"; | ||
cout << MaxString(str); | ||
return 0; | ||
} |
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,18 @@ | ||
#include <iostream> | ||
using namespace std; | ||
int main() | ||
{ | ||
int i, j, n; | ||
cout << "Enter number of rows: "; | ||
cin >> n; | ||
for(i = 1; i <= n; i++) | ||
{ | ||
for(j = 1; j <= i; j++) | ||
{ | ||
cout << "* "; | ||
} | ||
//Ending line after each row | ||
cout << "\n"; | ||
} | ||
return 0; | ||
} |