Created
September 9, 2012 17:27
-
-
Save jsharf/3685885 to your computer and use it in GitHub Desktop.
testing program for bijection problem
This file contains hidden or 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
#include <iostream> | |
#include <string> | |
using namespace std; | |
string translate(string input, string translation) | |
{ | |
string output = "ABCDEF0123456789"; | |
for(int i=0; i<input.length(); i++) | |
{ | |
if(input[i] > '9') | |
{ | |
output[i] = translation[input[i]-'A']; | |
} | |
if(input[i] < 'A') | |
{ | |
output[i] = translation[(input[i] - '0')+6]; | |
} | |
} | |
return output; | |
} | |
int main() | |
{ | |
string input = "AE9B5417C362D8F0"; | |
string translation; | |
getline(cin, translation); | |
string output = translate(input, translation); | |
cout << "0:" << output << endl; | |
int n = 1; | |
while(input != output) | |
{ | |
output = translate(output, translation); | |
n++; | |
cout << n << ":" << output << endl; | |
} | |
cout << n; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment