C++ :: Program To Sort Lists?
Aug 12, 2014
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.?
View 3 Replies
ADVERTISEMENT
Feb 19, 2013
i write code that's merge two linked list without sort ....
node * merage (node * list1, node * list2) {
// check witch list is empty
if (list1 == NULL) return list2;
if (list2 == NULL) return list1;
if ( list1 == NULL && list2 == NULL ) return NULL;
[Code].....
View 1 Replies
View Related
Mar 15, 2014
I am getting an error trying to convert from nodeType<Type> to nodeType<Type>* in my recursiveSort function and why this is happening.
#ifndef H_linkedListIterator
#define H_linkedListIterator
#include <iostream>
template <class Type>
struct nodeType {
Type info;
[Code] ....
View 7 Replies
View Related
Feb 24, 2013
I've written code for a selection sort algorithm to sort through a singly linked list, However, it only brings the smallest node to the front, but doesnt swap positions of any of the remaining nodes, even though they are not in order.
Input list: 3 6 17 15 13 15 6 12 9 1 2 7 10 19 3 6 0 6 12 16
Sorted list: 0 6 17 15 13 15 6 12 9 1 2 7 10 19 3 6 3 6 12 16
Code:
#include<stdio.h>
#include<stdlib.h>
struct node{
int val;
struct node *next;
[Code] ......
View 1 Replies
View Related
Apr 16, 2015
I want to get ride off lists and vectors in this program i also don't want to use classes, just want to use strings functions and structures...
#include <iostream>
#include <string>
#include <list>
using namespace std;
struct contact {
string name;
int studentiD;
[Code] ....
View 1 Replies
View Related
Mar 20, 2014
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) {;
[Code]....
View 5 Replies
View Related
Jun 16, 2013
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?
Here is the code so far (I know it isn't much..)
#include <iostream>
#include <fstream>
#include <string>
#include <limits>
#include <cstring>
using namespace std;
//Functions
void echoPrint();
[Code] .....
View 2 Replies
View Related
Sep 28, 2014
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
[Code] ....
View 12 Replies
View Related
Feb 15, 2015
Design a C++ Program to implement the following functions:
a.)the function for bubble sorting : int bubblesort(int*a,int size).
b.)the function for merge sorting : int mergesort(int*a,int size).
c.)the function for generating array of random elements: int generate(int*a,int size) which calls the function rand() in c++.
d.)Test both bubble sorting and merge sorting with 10,100,1000,10000,100000 and 1000000,4000000 integers.
The integers are from the array generated by part c).calculate the time spent in calling each sorting.you may use a function in <time.h>to get the current time. Draw curves to compare the speed performance between the two functions. The merge sorting algorithm implementation must use recursion. you are expected to define a global array for holding result from merging two arrays.otherwise,it may cause a lot extra money in recursion.
Hint 1:use the following format to calculate the time cost for bubble sort.
{……..
Time1=Get the current time(call a function in <time.h>);
Bbblesort(….)
Tme2=Get the current time(call a function in <time.h>);
Time_cost=the difference between time 1 and tim2;
…….
}
Print your program and test results
View 1 Replies
View Related
Apr 15, 2015
Been working on this program for a while. It's currently broken in several parts but it at least reads and stores the data into the arrays correctly. The problem is writing the sort function and the swap function. The other problem is writing both of these to keep the correct ages with the correct names.
/*
Write a program to allow the user to enter up to ten people with their age.
The names will be a full name consisting of a last, possibly a middle initial, and a first name.
The full name will be no longer than 40 characters in length.
The full will be stored in an array of strings, a two dimensioned array of characters.
The ages will be stored in an array of integers. Manage the arrays as parallel arrays.
Data entry will be from the keyboard and will read the full name followed by the age.
Data entry will terminate when the arrays are full or when nothing is entered for the full name.
Use a subroutine to enter the data and pass the arrays to the subroutine, do not use global arrays.
Once the data is completely entered, use another subroutine to print out the arrays to the screen.
Then use a subroutine to sort the data on the full names, ascending order.
Reuse the print subroutine and print the sorted data out to the screen.
Write another subroutine which sorts the data on age as the primary sort and full name as the secondary sort.
Finally reuse the print subroutine to print the data to the screen.
The main program will call the data entry function, followed by the print function, the name sort function, the print
function, the age sort function and finally the print function.
All data will be passed to the functions, no global data.
*/
#include <stdio.h>
#include <string.h>
#include <stdio.h>
#define SIZE 5
void input(char fullname[][25], int age[]);
void output(char fullname[][25], int age[]);
[Code] ....
View 14 Replies
View Related
Mar 25, 2014
I'm trying to code a Singly-Linked List(Double Pointers) selection sort program and I can't tell what the problem is. My compiler says no errors but when I run the program, it crashes right after I enter the values.
Code:
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
typedef struct node{
int elem;
struct node* link;
[Code] ....
The compiler that I'm using is Dev-C++.
View 2 Replies
View Related
Apr 7, 2013
I cannot get this program from having a continuous loop. I need to have a user-defined loop.
Here is what I have so far:
Code:
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int a,b,c,high,med,low;
[Code] ....
View 7 Replies
View Related
Apr 11, 2013
I am trying to run this program for Insertion Sort, But some how I am getting some problem:
#include<iostream>
int main(){
int i,j,key,n;
scanf("%d",&n);
int a[n];
[Code] .....
Error
In function 'int main()':
Line 10: error: ISO C++ forbids variable-size array 'a'
compilation terminated due to -Wfatal-errors.
View 2 Replies
View Related
Oct 7, 2013
I'm having trouble getting my sort function to work,
void Linkedlist::sort(int num)
{
node *q;
node *a;
int input=num;
[Code].....
I get a crash and I've narrowed it down to the last if statement. Also this function is meant to handle new members after 1 member has been added.
View 7 Replies
View Related
May 11, 2014
I'm having trouble implementing my radix sort program on the main .cpp file. Here is what the radix header file looks like::
#include <vector>
#include <queue>
using namespace std;
void distribute(const vector<int> &v, queue<int> digitQueue[], int pwr) {
int i;
for(int i=0; i < v.size(); i++)
digitQueue[(v[i]/pwr) % 10].push(v[i]);
[Code] .....
Here is what my main looks like:
#include <iostream>
#include <cstdlib>
#include <vector>
#include <queue>
#include "radix.h"
[Code] ....
My output:
sorted array is:
0 0 0 0 0 0 0 0 0 0
View 1 Replies
View Related
Jan 24, 2014
I'm trying to write a program to sort 2 ints on ascending/descending order, using function pointers. here is my code so far:
Code:
#include <stdio.h>
#include <stdlib.h>
int min_el(int a,int b);
[code]....
View 6 Replies
View Related
Nov 30, 2013
HelI have been tasked with creating a program which (1) takes in integer values from a user (until the user enters -1) and inputs these values into a linked list. This (2)original list is then to be printed out. The program then uses the algorithm "bubble sort" to (3)order the list in descending order before finally printing it out again.
I have managed to do this but I kind of cheated since I do not quite understand how to manipulate a linked list. What did was I took the values in the linked list and transferred them into an array and then did bubble sort on that array.how to do bubble sort on a linked list as well as how to print a linked list.
Code:
#include<stdio.h>#include<stdlib.h>
typedef struct node
{
int info;
struct node *link;
}Node, *NodePointer;
void printList (NodePointer head)
}
[code]...
View 4 Replies
View Related
Aug 19, 2013
Example radix sort function to sort an array of 64 bit unsigned integers. To allow for variable bin sizes, the array is scanned one time to create a matrix of 8 histograms of 256 counts each, corresponding to the number of instances of each possible 8 bit value in the 8 bytes of each integer, and the histograms are then converted into indices by summing the histograms counts. Then a radix sort is performed using the matrix of indices, post incrementing each index as it is used.
Code:
typedef unsigned long long UI64;
typedef unsigned long long *PUI64;
PUI64 RadixSort(PUI64 pData, PUI64 pTemp, size_t count) {
size_t mIndex[8][256] = {0};
/* index matrix */
PUI64 pDst, pSrc, pTmp;
size_t i,j,m,n;
UI64 u;
[Code]....
View 9 Replies
View Related
Feb 11, 2015
#include <iostream.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
class Player {
private:
char name[20];
int score;
[Code] .....
View 5 Replies
View Related
Mar 22, 2013
how to sort a 1D array using function sort().but if i have a 2D array how do i sort only 1 row of it (or column)?
View 2 Replies
View Related
Feb 19, 2014
You will write a program that uses a multidimensional array having 3 rows and 8 columns and sorts each of the rows using both a bubble sort and a selection sort.
You must declare the array inside of main. You will have a for loop containing the calls to bubbleSort and selectionSort. You need to pass into function bubbleSort and selectionSort the following: 1) each column of the multidimensional array, 2) the size of the column, and 3) a particular row number of the multidimensional array to be used for printing out the "pass" shown on the following pages.
I keep getting an error that the identifier for bubbleSort and selectionSort is not found. (Error C3861) Also, I feel like I'm missing something in int main() to get it to sort properly.
# include <iostream>
using namespace std;
int main()
{
[Code].....
View 14 Replies
View Related
Nov 7, 2013
I got a permutation question, I got two different std::list:
list<string> slist;
slist.push_back("str111");
slist.push_back("str222");
slist.push_back("str333");
list<int> ilist;
ilist.push_back(100);
ilist.push_back(200);
I need the permutation for both two lists, the result should be like this:
#include <iostream>
#include <string>
#include <list>
#include <algorithm>
using namespace std;
template <typename value_t>
void dump_list(const list<value_t>& lst) {
[Code] ....
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.
View 5 Replies
View Related
Dec 27, 2013
I'm trying to set up a simple implementation of a double linked list. I can't make it fly.
Code:
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
[Code] ...
I seem to create a root vertex, but I can't establish if I connect sub nodes to my list.
View 13 Replies
View Related
Mar 6, 2015
I am merging two linked list but the output of the program is not printing insert
Code:
typedef struct Merge
{
int info;
[Code].....
View 1 Replies
View Related
Oct 14, 2013
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.
View 1 Replies
View Related
Apr 5, 2013
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)
g(month) = month+13 (if month <=2)
= month+1 (otherwise) Code:
struct date {
}
[code]....
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.
View 2 Replies
View Related