solidtuber's Profile User Rating: -----

Reputation: 0 Apprentice
Group:
Members
Active Posts:
20 (0.02 per day)
Joined:
20-March 12
Profile Views:
478
Last Active:
User is offline May 20 2014 04:48 AM
Currently:
Offline

Previous Fields

Country:
AU
OS Preference:
Windows
Favorite Browser:
Chrome
Favorite Processor:
Intel
Favorite Gaming Platform:
PC
Your Car:
Nissan
Dream Kudos:
0
Icon   solidtuber has not set their status

Posts I've Made

  1. In Topic: How to search an array and list the possible values...

    Posted 23 Sep 2013

    I had a look at it, didn't really help me out though...
  2. In Topic: How to search an array and list the possible values...

    Posted 22 Sep 2013

    Managed to write this up, but it's listing every word instead of the words with three z's

    Word* Dictionary::findzs()
    {
    	int wordIndex = 0;
    	cout << "List : " << endl;
    	while (wordIndex < MAX_WORDS) {
    		string subString = "zzz";
    		string word1 = myWords[wordIndex]->word;
    		if (word1.find_first_of(subString)) {
    			cout << word1 << endl;
    			wordIndex++;
    		}
    	}
    	return myWords[wordIndex];
    }
    
  3. In Topic: How to search an array and list the possible values...

    Posted 21 Sep 2013

    View Postsalazar, on 22 September 2013 - 03:18 AM, said:

    Use findFirstOf which is in the string class. Compare its return value to npos, a value indicating that the index returned is past the length of the string. This means the string does not contain the value for which you are searching.

    string substring = "zzz";
    string word = myWords[wordIndex]
    if (word.findFirstOf(subString);
    {
        cout << word << endl; 
    }
    
    


    Hey cheers, I'm getting an error wordIndex is undefined and im not sure why...
  4. In Topic: Need help with time complexity using Big-O

    Posted 9 Sep 2013

    Hey thanks would the total time complexity of algorithm_1 be?

    O(n^2 log n)
    or
    O(log(n))+O(n log(n))+O(n^2 log(n))
  5. In Topic: Need to convert a struct program to class

    Posted 8 Sep 2013

    #include <iostream>
    #include<string>
    #include <fstream>
    #include <ctime>
    
    using namespace std;
    #define MAX_WORDS 106184
    
    
    struct Word {
    	string word;         
    	string definition;   
    	int usageFrequency;  
    
    	//Constructor
    	Word(const string &theWord, const string &theDefinition)
    	{
    		word = theWord;
    		definition = theDefinition;
    		usageFrequency = 0;
    	}
    };
    
    int main(int argc, char* argv[])
    {
    	string dictionaryFileName = "dictionary.txt";  //name of the dicionary file
    	Word *myWords[MAX_WORDS];                      //array of 'Word' pointers
    	int wordCount = 0;                             //number of words loaded  
    
    	//attempt to open the file
    	std::ifstream dictionaryFile(dictionaryFileName);
    	
    	//check if the file was opened
    	if(dictionaryFile.is_open())
    	{
    		//start a timer (clock_t is normaly a 'long')
    		std::clock_t start = std::clock();
    
    		//load the file
    		cout << "Loading the dictionary";
    		std::string word, definition, type, blank;
    		
    		while (std::getline(dictionaryFile, word)        &&
    			   std::getline(dictionaryFile, definition)  &&
    			   std::getline(dictionaryFile, type)        &&
    			   std::getline(dictionaryFile, blank))
    		{
    
    			myWords[wordCount] = new Word(word, definition);
    			wordCount++;
    
    			//show a progress bar
    			if(wordCount % (MAX_WORDS/10) == 0) {
    				cout << '.';
    			}
    		}
    		
    		//close the file
    		dictionaryFile.close();
    			
    		//let the user know what happend
    		double duration = ( std::clock() - start ) / (double) CLOCKS_PER_SEC; //measure duration
    		cout << endl <<"Done (" << wordCount << " words in " << duration << " seconds)." << endl << endl;
    
    		string searchWord = myWords[wordCount/2]->word;
    
    		//search for the word
    		cout << "Testing word search for: " << searchWord << endl;
    		start = std::clock(); //restart the clock
    		int wordIndex = 0;
    		while(myWords[wordIndex]->word.compare(searchWord) != 0) {
    			wordIndex++;
    		}
    
    		//show the result of the search
    		duration = ( std::clock() - start ) / (double) CLOCKS_PER_SEC; //measure duration
    		cout << "(in " << duration << "seconds) " << myWords[wordIndex]->definition << endl << endl;
    	}
    	else
    	{
    		//normally this means the file was not found, copy the file to your solution!
    		cout <<"ERROR: Could not open " << dictionaryFileName << endl;
    	}
    
    	//done
    	system("pause");
    
    }
    
    

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

solidtuber hasn't added any friends yet.

Comments

Page 1 of 1
  1. Photo

    rayA Icon

    16 Mar 2014 - 06:54
    hey just wondering if you still around on here?
Page 1 of 1