#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;
}
}
суббота, 7 января 2012 г.
One-word convention
Подписаться на:
Комментарии к сообщению (Atom)
Комментариев нет:
Отправить комментарий