|
-
December 22nd, 2011, 07:39 PM
#1
One-word convention
Hi
Code:
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(int argc, char *argv[])
{
vector<string> dic;
if (argc != 2) {
cerr << "You must specify vocabulary (E.g. c:\\voc.txt)\n";
return 33;
}
ifstream a(argv[1]);
char b[256];
while (a.getline(b, sizeof b))
dic.push_back(string(b));
string secret = "overturnedcomma";
for (int w=0; w < dic.size(); w++)
{
int w_len = dic[w].size();
int f;
char *flags = new char[w_len];
for (f=0; f < w_len; f++)
flags[f] = '-';
string word = dic[w];
int secr_len = secret.size();
for (int n=0; n < secr_len; n++)
{
char d = secret[n];
for (int s=0; s < w_len; s++)
{
if (word[s] == d && flags[s] == '-')
{
flags[s] = 'x';
break;
}
}
}
int Accumulator = 0;
for (f=0; f < w_len; f++)
Accumulator += (int) ( flags[f] == 'x' ) ;
if (Accumulator == w_len)
cout << word << endl;
delete[] flags;
}
}
-
December 23rd, 2011, 01:48 AM
#2
Re: One-word convention
Hi,
Did you have a question...?
Best Regards,
BioPhysEngr
http://blog.biophysengr.net
--
All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.
-
December 24th, 2011, 07:59 PM
#3
Re: One-word convention
Maybe question is "How this algorithm can be used in practice?".
I see few areas, for example we can encode book/song/film title and use another words
to refer to that title. For example Garbage song "Dog new tricks" can sound like
"network doctrine".
---
-
December 25th, 2011, 09:18 AM
#4
Re: One-word convention
 Originally Posted by BioPhysEngr
Hi,
Did you have a question...?
How this algorithm can be used in practice maybe?
If we take book/song/film their title can be encoded to set of words - Garbage song "Dog new
tricks" will sound like "network doctrine".
Also it is possible to create secret message (very short) that lately can be decrypted.
If you have a letter with obvious informative words it can be collapsed to such message.
Interesting, what type of GUI can be constructed for this kind of text processing?
Elena and Grizzlies -
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|