What I want to create is a program that sorts through a huge list (millions of lines).
I want it to get rid of any line that contains a word that isn't in an English dictionary.
Example list:
00sdfdsf ahdadsg angel ksjflsjdf green green000 carrot
and it would go through millions like that, giving me only:
angel green carrot
as my new list.
How could I go about this? What programs would I need? And at the very least how can I remove unwanted things like numbers, double letters, underscores etc.?
I need to create a program that lists off each digit of an integer and then display the sum off all the digits in that integer. I know that sepereatly the sum function i wrote works. But the first part which i try to list off the digits work but in reverse order which i dont know how to correct. and for some reason that i cant figure out this is affecting the sum output.
#include <iostream> using namespace std; int digcount (int x) {;
Let's say we have entities like lines and circles. And each entity can have a pen attached. And a pen is a color and line width. All entities needs to be manipulated through a operations interface. All entities added to the program needs to be added through using a factory pattern.
So we end up something like (pseudo code)
class Line // for immutable objects { .. .. } class MutableLine extends Line //for mutable lines { } MutableLine line=factory->newLine(20,20,50,50); // Create a new line entity
[code]....
So, essentially I want no code to be able to operate directory on entities, unless during creation of the object (color, layer, line width etc...) so I am planning to create Mutable versions of all entities besides the immutable versions.
When requested for selected entities or all entities, I am planning to return a list of immutable objects and in fact I am planning to return a new copy so it's not possible to operate on anything directly.
The reason is that I am planning to create different storage backends swell, so I can operate on entities in a database, or shared memory... stuff like that. At least to hide the internals and provide a stable API.
My questions are:
How can I make sure that people don't do 'tricks' casts for example to a mutable version to change objects directly?
void armazenaFA( std::vector <int> &vFA) // this function only knows about vFA { vsFA[n] [m]= simTime().dbl(); OR vsFA[n].push_back(simTime().dbl()); }
I'm new to programming, and I'm working on my second c++ program right now. Its a dating service where you read data from an input .txt file and store into a linked list, so then you can search, and modify the data. The text file is in this format:
M Dr.Gregory House,237-8732 7 Vicodin,Guitar,Piano,Motorcycles,Television,Food,W hiteboards.endl; (all on a single line).
First, is the sex (M or F), then the person's name, phone number, number of interests, then a list of their interests (with commas between each one, and a period at the end.) and then if they have a match you put their name there and put endl; after.
The main problem I'm having is setting up the link list, how to get it to read those as variables in the text, I know you have to use delimiters, but I can't quite figure out how to use them. You also have to keep two lists, one for males, and one for females in the output file. How do I do this? Is that a double linked list?
I have a local student and international student class inherit from student class. read and print are virtual functions. After i have set all the member variables when i wan to print out all the student information, my program crashes.
Code: int main() { clsUniversityProgram objProgram[3]; for (int x = 0; x < 3; x++)
I'm writing a program of a stock market where i read from a file and sort with symbols and percent gain/loss. I have completed sorting with symbols but having trouble establishing the percent gain loss. First i designed and implemented the stock object. call the class stockType. main components of a stock are the stock symbol, stock price and number of shares. Second we have to create a list of stock objects. call the class to implement a list of stock objects stockListType. To store the list of stocks, i declared a vector and called the component type of this vector stockType. Because the company requires me to produce the list ordered by percent gain/loss, i need to sort the stock list by this component.
However, i'm not to physically sort the list by component percent gain/loss; instead i should provide a logic ordering with respect to this component. To do so i added a data member, a vector to hold the indices of the stock list ordered by the component percent gain/loss and i called this array indexByGain. I am going to use the array indexByGain to print the list. The elements of the array indexByGain will tell which component of the stock list to print next. I have trouble going about how to implement the function sortStockGain(). Below is my entire code and the txt file. I have sort symbols working but dont know how to implement the sort by gain.
I was given a task to convert infix to post fix using both linked lists and stacks in the code so this is what i have written but the problem is it is giving me same error at three different places "missing function header(old style format?)
#include <iostream> #include <string> using namespace std; const int size = 100; class stack{ private: // Declare a structure for the list
This is probably a very basic question, but I need to create two vectors and then loop through the vectors and output each pair that is found.
The user will input min1 and max1 with step1 for the first vector and min2 and max2 and step2 for the second vector. Then the loops will go through and return the combinations will return each pair of the two vectors.
So if I input min1=1 and max1=10 and step1=1 and same for vector two the return would be:
[1,1] [1,2] . . . [10,10]
This is for part of a homework assignment, but I can't continue on the assignment without first getting this simple part to work.
See, there are two do while loop, if I need a permutation with more than two lists, there'll be more and more do-while loops, that's make code looks ugly, I wonder if stl has some tricky way that can do this with just one next_permutation.
In our homework assignment it states to, "write a set of dynamic linked lists" and so on. Now, the problem I'm confusing myself is at the storage inside of each node. To my understanding, each node contains the prev and next nodes, but also a pointer to the data, in this case being a string. He has asked us to manage these strings as rows of chars such as
char[0] = c // first node being addressed here char[1] = a char[2] = t char[3] = char[4] = d // second node starting here char[5] = o char[6] = g char[7] =
I have written my code where each node is holding a string, not separated as shown above... my question is to how you can build your doubly linked list where each node is being address a set of chars.
New to this C stuff, and was going through Kochan's book Programming in C and got to chapter 9 structured lists.There's this problem that requires you to set a Variable N that calculates days.
N = 1461 x f(year, month) / 4 + 153 x g(month) / 5 + day where f(year, month) = year-1 (if month <=2) =year (otherwise)
I was having issues getting the right values for N so I tried to see what T1.year gives me when I type in firstDay.month=02, firstDay.day=08 and firstDay.year=1999, and I got 8. According to book I should be getting 1998.
I'm trying to do is let the user type in something like A654321 (note: these are ALL the characters, i.e. 'A', '6', '5', '4', etc..) Then I just want to display that current number back to them and I am getting some weird pointer memory allocation error..
#include<iostream> using namespace std; //To rename data-type "int" or integer to "element" (Both are equivalent).. typedef int element; //To declare an appropriate SENTINEL. char const SENTINEL = '#';
[code]....
It seems like the first part that it bugs out at is in my Clean(); function..
Unhandled exception at 0x01383FBB in VegMe.exe: 0xC0000005: Access violation reading location 0xCCCCCCD0.
It doesn't like head = head->next; ?Also, ignore the ReverseList(); function, it is not being used as of now.
I am working on building a graph of a maze problem using an adjacency list and my own custom class Node.
Each Node has a vNum and jumpAmount integer variable, the vNum is the unique key.
If I have an array of lists of Node objects declared by: Code: forward_list<Node> adjacencyList[10] I skip the 0 row and only use 1-9. It makes more sense logically for my program and Im not worried about wasted memory at this point.
How could I go about traversing and outputting member variables for all the Nodes in each list in my array?
where the values in brackets are the nodes that have an edge with the ith row node. Had to put it in code tags for the thread to be allowed to post.
I am using the forward_list library for my list functions and this is where my problem arises. The cplusplus.com - The C++ Resources Network website iterates through the list using:
Code: for ( auto it = mylist.begin(); it != mylist.end(); ++it ) std::cout << ' ' << *it;
Obviously this works for ints, doubles, etc, but not objects with member variables. My attempt to replicate this code for my problem looks like:
Code: for( int i = 1; i < 10; ++i ) { cout << "Node " << i << " -> { "; for( Vertex it = adjList[i].begin(); it != adjList[i].end(); ++it ) { cout << it.getVNum() << ", "; }}
I have to come up with user defined conversions for this to work and I have never done such a thing. Is there a way to go about doing this to avoid user defined conversions, because if there isnt I feel like attempting to do this specific problem might be a little too difficult for someone who hasnt defined any custom conversions.
Potentially, I could write my own List class and have a next pointer member variable that points to the next object in the list and use that to use a dot reference to a get function to display member variables. This is how I learned linked lists back in my Data Structures class. However I am trying to avoid that for the time being, as that would be a lot more code to implement rather than just figuring out how to use the forward_list library.
I am writing a Windows Form program, and currently it has 3 Lists. I need to loop through all three, and use each possible combination, so am using three nested for loops.
I found that if the outer loop had less elements than one of the inner loops/lists, some were missed off, as I need to save all the possible combinations of list a + b + c.
This is what I wrote:
Code: public int CalculateOrderToProcessLists()//for three lists { int order = 0; if (sListOne.Count() > sListTwo.Count() && sListTwo.Count() > sListThree.Count()) { order = 123;
[Code ....
My problem is I would like to be able to have 4 (or more if possible) lists, and to calculate what order to process the lists will be exponentially more complex.
Any better way of comparing the sizes of the lists, so that I can use the nested loops of say 4 lists, but being able to use N number of lists would be awesome.
I am having some trouble getting a 3d array of pointers to link up with a linked list for each of the array elements. the 3d array of pointers is declared like this:
Code:
struct particle *cell[MAXCELLS][MAXCELLS][MAXCELLS]; and there are linked lists declared like this: Code: struct particle { /* structure for particles */ double sw[3]; /* square well components */ double hs[3]; /* hard sphere components */ double u[3]; /* unit vector for rotations */ struct particle *link; };
I want to get the array pointers 'cell[x][y][z]' to point to the first observed particle in a function next to main, something like this:
Code:
void generate_list(){ int i,j,k,l; /* determine the number of cells to decompose the simulation box in each of x, y and z directions*/ int(cells_x) = floor(boxX/cell_size); int(cells_y) = floor(boxY/cell_size); int(cells_z) = floor(boxZ/cell_size); /* initialise the array of pointers to NULL */ for (j=0;j<cells_x;j++){
[Code]...
I am getting a pointer type cast error when I compile "assignment from incompatible pointer type",
I have to write a program that reads from a text file, which contains a list of stock hourly prices and the company names. Something like this:
78.52 82.56 75.10 71.97 Water Company 22.40 25.68 21.37 22.96 Mega Shipping Inc
Each company data will be kept in a structure that contains: a pointer for the name, an array of the prices, and the average price for the day. The structures will be kept in a linked list. Each node structure will contain a pointer to one company data, and a pointer to the next node structure.This is all I have so far..
We have to sort the nodes alphabetically. My question is, how do I read the data from the file one line at a time, and insert them alphabetically one by one?
I'm trying to compare a single value with a value from my Linked list and if they are same, I want to add the value from the list to new list. In other words I want to create a new List with values with the first one. Here is the code that I made, but it's not working.
This is the code with which I search in the first list for a node with a value. In the main() function I have A.find_city(), so it can start from the start_pointer from the first list:
void List::find_city() { List *temp1; int b = 0; char city[20]; cout << "Enter city: "; cin >> city; temp1 = start_ptr;
[Code] ....
This is the code with which I add a node to the new list:
I have this code that I need to memorize for my final. Memorizing code is easy for me, but I'm trying pretty hard to fundamentally understand the functions, and what they are doing (even using pen and paper, to draw and trace).For example, in the push function below, I understand everything, except why I'm setting ptr = p. I feel like p should be equal to NULL, then the next node I push should be equal to p, etc.
Stack & Stack::push(double x) { Node * p = NULL; try { p = new Node; }
[code].....
Also, are LL Queues that hard to implement once you can do them w/stacks - That will probably be something I have to code for my final, as well. Below is the full code for my Stack class.
#include <iostream> #include <string> #include <stdlib.h> using namespace std; class Stack }
I do not know how to write the part indicated in Bold that represents the number of elements of contour. As seen from the code used for the tesselation OpenGL.