The words successfully sorted but in the worng order.

Put your programming skills to the test in these challenges.

The words successfully sorted but in the worng order.

Post by t3rm1n4t0r0905 on Thu May 28, 2015 6:30 am
([msg=88241]see The words successfully sorted but in the worng order.[/msg])

So, I'm trying to make a word unscrambler for programming mission 1 using c++ with the following code:
Code: Select all
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
   vector<string> wordlist;
   vector<string> scrambledwords;
   vector<string> sortedwordlist;
   string temp;
   int count;
   ifstream fin;

   fin.open("scramble.txt");
   while(!fin.eof()) {
      fin >> temp;
      scrambledwords.push_back(temp);
   }

   fin.close();
   fin.open("wordlist.txt");

   wordlist.resize(0);
   while(!fin.eof()) {
      fin >> temp;
   


but it successfully sorted the word but it put in the wrong order
for example from the following words[list=]
raocfrdw
yaolpby
ehcetra
tamotc
dtlrnpoa
rownsb
odniig
alyewel
srlpoia
eitsoob

[/list]
To:
[list=]
playboy
crawford
teacher
tomcat
portland
walleye
polaris
bootsie
browns
indigo

[/list]
Any fix for the source code to make the sorted words in order?
t3rm1n4t0r0905
New User
New User
 
Posts: 1
Joined: Thu May 28, 2015 6:16 am
Blog: View Blog (0)


Re: The words successfully sorted but in the worng order.

Post by sanddbox on Mon Jun 01, 2015 7:23 pm
([msg=88291]see Re: The words successfully sorted but in the worng order.[/msg])

You didn't post all of your code. If you re-post it properly I can try to help.
Image

HTS User Composition:
95% Male
4.98% Female
.01% Monica
.01% Goat
User avatar
sanddbox
Expert
Expert
 
Posts: 2344
Joined: Sat Jul 04, 2009 5:20 pm
Blog: View Blog (0)



Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests