Created
September 6, 2019 01:08
-
-
Save RolandWarburton/5aefdf243ec7bac0c104d11ba092c726 to your computer and use it in GitHub Desktop.
SWE20004 assignment 1 encoder
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
void encode4PlusDigits(int value) | |
{ | |
// slices an int number. eg. | |
// a[1,2,3] = a[1] = 2 | |
int valueLen = to_string(value).length(); | |
int sliced[valueLen]; | |
for (int i = 0; i < valueLen; i++) | |
{ | |
sliced[i] = value % 10; | |
value /= 10; | |
this->data.push_back((sliced[i] * 3) % 10); | |
} | |
// reverse the vector because i sliced the array the wrong way around | |
reverse(this->data.begin(), this->data.end()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment