473,383 Members | 1,829 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

look for congruence

Hello,
I want to sort several words in a textfile in view of alphabet like
this:
stop is opst
manage is aaegmn.
I think it will work with:
#include <algorithm>

sort (word.begin(),word.end());
system(sort("file.doc > newfile.doc"));

After that I want to read this new file and look for congruence. What
is a capability to compare all this word-orders?
Many thanks for reply.
Bjoern
Jul 22 '05 #1
2 1645
BjoernJackschina wrote:
Hello,
I want to sort several words in a textfile in view of alphabet like
this:
stop is opst
manage is aaegmn.
I think it will work with: #include <algorithm>

sort (word.begin(),word.end());
Either you've included <algorithm> inside function body, or you've tried
to perform the sort outside a function body. Either way, this isn't
what you want to do. Also, how do you define "congruence?" The
std::sort algorithm sorts lexicographically by default.
system(sort("file.doc > newfile.doc"));
/* ITYM: */ system( "sort file.doc > newfile.doc" );
After that I want to read this new file and look for congruence. What
is a capability to compare all this word-orders?
Sorry, not sure what you mean. :(
Many thanks for reply.
Bjoern

Jul 22 '05 #2
On 8 May 2004 04:55:10 -0700 in comp.lang.c++, ja*******@hotmail.com
(BjoernJackschina) wrote,
stop is opst
manage is aaegmn.
I think it will work with:
#include <algorithm>

sort (word.begin(),word.end());
system(sort("file.doc > newfile.doc"));


You have not mentioned how the sorted anagrams will get back out to any
file. Is your data too big to hold in memory? Please compare what you
are doing with the std::map approach someone suggested earlier. Perhaps
you need to describe your requirements for us again?

#include <iostream>
#include <fstream>
#include <string>
#include <map>
#include <algorithm>
using namespace std;

int main()
{
string word;
map<string, string> wordmap;
ifstream input("file.txt");
while (input >> word) {
string anag = word;
sort (anag.begin(), anag.end());
if (wordmap.find(anag) != wordmap.end()) {
if (word != wordmap[anag])
cout << wordmap[anag] << "\tis\t" << word << '\n';
} else {
wordmap[anag] = word;
}
}
}

Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: phil | last post by:
I can't find, anyone know the unicode symbol CONGRUENT. either tilde over equal or triple tidde would do. Thanks.
0
by: FAQPoster | last post by:
An HTML version of this document is available at: http://www.mvps.org/access/netiquette.htm Feeling left out? Alone? Wondering why everyone's ignoring you? Or why you're being flamed for what...
4
by: Jozef | last post by:
Hello, I have forms in my database that use grey as the back color. When I convert them to XP, They all look goofy. The grey becomes two tone. The grey used in the controls are dark, the grey...
0
by: eselk | last post by:
I'm using Access 2000. I've got a basic look-up combobox on a form (moves to selected record on update). The key field and the look-up field are both indexed, and the speed if fast enough for me....
20
by: Maurice | last post by:
Hi all, I have an application, designed in Visual Studio 2005, which will run mainly on Windows XP computers. If I run the application on a Windows XP computer having the Windows XP Theme...
4
by: Laurel | last post by:
Is there a way, in the debugger, to look at the contents of a dataset? I tried drilling down into my dataset and it's like exploring the registry! Anyway, I didn't find anything useful. The code...
5
by: Neil Cerutti | last post by:
For use in a hand-coded parser I wrote the following simple iterator with look-ahead. I haven't thought too deeply about what peek ought to return when the iterator is exhausted. Suggestions are...
11
by: Peted | last post by:
Im using c# 2005 express edition Ive pretty much finished an winforms application and i need to significantly improve the visual appeal of the interface. Im totaly stuck on this and cant seem...
1
by: ntraviglia | last post by:
Can anyone help? I have to write a zellers congruence program with visual. Anyone have any sample code or maybe the actual zeller program in visual they can give me, I am totally lost.
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.