Skip to content
This repository has been archived by the owner on Jan 31, 2024. It is now read-only.

Commit

Permalink
added Reverse()
Browse files Browse the repository at this point in the history
  • Loading branch information
Copy05 authored Oct 18, 2021
1 parent 6a92c7e commit 3b4c7d1
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion consoleutilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,21 @@ namespace as {
void ChangeColorText(Color colorID) {SetConsoleTextAttribute(h, colorID); }
}

// Contains alogrithms.
namespace alogrithm {
// Coverts a binary string into a integer

// Reverses a string
string Reverse(string& str) {
int n = str.length();
for (int i = 0; i < n / 2; i++)
{
swap(str[i], str[n - i - 1]);
}

return str;
}

// Converts binary into decimal
int toBinary(string bin, int length)
{
int val = 1;
Expand Down

0 comments on commit 3b4c7d1

Please sign in to comment.