If you can sort one column you can sort two. It's just a matter of using the second column to drive your sort, and making sure that when you copy a row, you copy both columns.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
I personally don't really get the project, can you give me an example of an input and output..? thx
ProgrammersTalk
Junior Poster in Training
84 posts since Jun 2007
Reputation Points: 21
Solved Threads: 7
you're not necessarily to use multi dimentional arrays right? i guess for me it's easier to just use one dimentional array, but compare the index. Make sure the comparison is on the same index. would that work for you?
ProgrammersTalk
Junior Poster in Training
84 posts since Jun 2007
Reputation Points: 21
Solved Threads: 7
Um I know this is marked as solved, but I really don't get the deal with this signature malarky?
Is there any logic?
retarded.txt
Pans
stop
Pots
opt
Sit
Pots
it's
snap
pedantic.cpp
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <cctype>
using namespace std;
struct to_lower
{
int operator() ( int ch )
{
return std::tolower ( ch );
}
};
class Anagram
{
//define public member functions
public:
string removeJunk ( string w )
{
string newWord = "";
int length = w.length();
std::transform ( w.begin(), w.end(), w.begin(), to_lower() );
for ( int i = 0; i < length; i++ )
{
if ( isalpha ( w[i] ) )
{
newWord = newWord + w[i];
}
}
return newWord;
}
void getAnagrams ( string array )
{
ifstream read ( "C:\\retarded.txt" ); //read file
int sssh;
sssh = array.length();
char alphabet[28] = {"@abcdefghijklmnopqrstuvwxyz"};
int hohoho[26];
int Blahh[26];
for ( int i = 1; i < 27; i++ )
{
hohoho[i] = 0;
}
for ( int a = 0; a < sssh; a++ )
{
for ( int j = 1; j < 27; j++ )
{
if ( array[a] == alphabet[j] )
{
hohoho[j]++;
}
}
}
string x;
while ( read >> x )
{
string y = removeJunk ( x );
int size;
size = y.length();
for ( int i = 1; i < 27; i++ )
{
Blahh[i] = 0;
}
for ( int i = 0; i < size; i++ )
{
for ( int j = 1; j < 27; j++ )
{
if ( y[i] == alphabet[j] )
{
Blahh[j]++;
}
}
}
int counter = 0;
for ( int k = 1; k < 27; k++ )
{
if ( Blahh[k] == hohoho[k] )
{
counter++;
}
}
if ( counter == 26 )
{
cout << y << " ";
}
}
read.close();
}
};
int main ( void )
{
//create a test object
Anagram test;
ifstream in ( "C:\\retarded.txt" ); //read the file
string line;
while ( in >> line )
{
string tmp = test.removeJunk ( line );
test.getAnagrams ( tmp );
cout << "\n";
}
in.close();
cin.get();
}
Output
pans snap
stop pots pots
stop pots pots
opt
sit its
stop pots pots
sit its
pans snap
Surely then all you'd need to do is eliminate duplicates from the output?
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
>using the signatures made the process faster
Prove it.
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439