I've tried searching for answers around the web but everyone is using syntax that We haven't been taught before in class yet. I understand that the string library is probably the most efficient way of doing this but is there a way without using that library? Like using if, for, while etc. instead?
I've been told that using anything else other than the string syntax is far to complex but I think the more complex it is the more I will understand it.
I'm trying to write a program that reads in from a .txt file the movie title, rating, director, actors etc. All I want to do is to just sort movie titles alphabetically and print all its attributes(director, actors). I tried using sort( movies.begin(), movies.end()) method, but it doesn't work.
A teacher has asked all her students to line up single file according to their first name. For example, in one class Amy will be in front of the line and Yolanda will be at the end.
Write a program that will read in a file of names. Names should be read until there are no more names to be read. Use LineUp.txt as a test file for your program.
Once all the names have been read in display which student will be at the front of the line and which one would be at the end of the line. You may assume that no two students have the same name.
These are the name in the LineUp.txt file if needed: Cooper Gavin Joseph Sierra Kacie Dylan Kaylee Will
I have a homework assignment in C++ where I have to: "Write a program which asks user to input 10 students names. Store them in an array. Convert all the names to UPPERCASE without using any built-in functions. You must write the function to do that yourself. Lastly, sort the name in alphabetic order."
Here is my code so far, but my program won't compile, and the message it gives me is gibberish.
#include <iostream> using namespace std; void sortNames(string name[], int cap); void toUpper(string name[]); int minIndex(string name[], int i); void sort(string name[]); void swap(string name[], int i, int j);
I am trying to read information in from a file, each line of which contains a name in the form 'last, first middle'. I can successfully open the file and read it into an array that is roughly 2500 string in size. The problem comes when I try to sort the array into alphabetical order. I am using a sorting algorithm that we were instructed to use, found in our book. It is shown in the code. I would add the file that needs to be opened, but it is a few thousand lines long.
The error I am getting is: Unhandled exception at 0x00A28628 in PeopleSearch.exe: 0xC0000005: Access violation reading location 0x00CC400C.
and I know it has to do with the sorting algorithm from using break points and running the program with that section commented out. I am stumped to why it is giving this error, as it seems that it is trying to access the array outside of the bounds of the array, but it shouldn't be
I have been reading up on arrays and string array. I created a string string text[0] and it is defined by user input. I am trying to sort the input. I want Michael to read Macehil.
When I wasn't using an array and just a string I did this:
return sort(text.begin(), text.end()); a
And it worked fine. Do I need to change my string into a char? If so, would I static cast that?
I'm using a database and im trying to sort a 2D array info[51][10] that contains 51 pieces of records and 10 different fields for each record. And, now I'm trying to sort a desired field in the 2D array alphabetically.
However, the other fields within the same record should be swapped together. (So that the information of the same records stays together).
Also, I am constantly experiencing a run-time error. Sometimes my program works sometimes the whole thing crashes... By opening the code in different folders sometimes works. But the problem is still here. Is there any way to fix this error?
bool swapped =true; int j=0; string tmp[10]; swapped =true; j=0;
I am writing a code that is supposed to read a resistor code and determine the resistance nominal, lower, and upper and write those numbers to a file in various ways. I already accomplished writing to the file output and the file nominal but now I have to sort the file nominal by the nominal readings. I managed to tokenize the string so I could read the second part of the string .....
Write a function to read and display the contents of names and marks. You then ask the user for a name and using the linear search return the index to the user. If -1 is returned then the name is not in the file. Otherwise write out the name and mark for that student.
Next, sort the arrays, write them out and then ask the user for a name to search for. This time use the binarySearch to return -1 or an index. Display the student's name and mark if found.
void getNames(ifstream& inStream, string names[], int marks[], int numElts); int linearSearch(const string names[], int numElts,string who); int binarySearch(const string names[], int numElts,string who); void selectionSort(string names[], int marks[],int numElts); void displayData(const string names[], const int marks[], int numElts); [Code] ....
Now I have worked up some stuff in parts but I am so lost and confused with these specific requirements: Previous questions asked me to sort out a linear search, a binary search and
LINEAR SEARCH:
int searchList(int list[], int numElems, int value) { int index = 0; // Used as a subscript to search array int position = -1; // To record position of search value bool found = false; // Flag to indicate if value was found
My program reads a string of characters. Prints all occurrences of letters and numbers, sorted in alphabetical and numerical order. Letters will be converted to uppercase.Other characters are filtered out, while number of white spaces are counted.
the problem is it crushes when i run the program
Here is my code
#include <iostream> const int SIZE = 100; using namespace std; int main() { char *pStr, str[SIZE] = "", newStr[SIZE] = "", ch; int count = 0, i = 0, j;
I'm currently trying to code a sorting algorithm program.
let's asume I have a string given: aa, aaa, bbb, bas, zya!
I first of all want to split the given string on commas and '!' tells the program the string ends here and is no part of the last word. lower and upper case is not important at the moment. trying to implement everything with standard libary
output should be like that ofc: aa aaa bas bbb zya
I already looked into the bubble sort algorithm and I think it benefits my needs. Just wanted to know how I should start out with the string split.
I have a problem I am working on where I need to sort some data based on the values of a string of bits. The strings look like this,
010000001110000000
there are 18 bits, 1 means a feature is present, 0 means the feature is absent.
Each of these string has 4 on bits. I need to sort them such that I have the longest possible runs with 3 of the same on bits. It doesn't matter which 3 bits are on, I am just looking to order them in blocks with the longest possible runs. As a second step, the ordered blocks will be sorted by size large>small.
The following data is ordered like I need it to be.
Code: // block 1, run of 12, keys 1,2,11 are identical (key 12 is also identical) 011000000001100000 011000000001100000 011000000001100000 011000000001100000
[Code] .....
This is the sort order that I am looking for. I need to be able to take a list of the bit strings in any particular order and sort them into the order above. The algorithm would need to recognize that there are 4 on keys and then look for groupings of three common on keys.
This is more of an algorithm question than one about specific implementation in code. I generally assume that most programming problems have been solved one way or another, so I don't know much about analyzing and manipulating strings of bits.
Is there a standard method for this kind of pattern recognition?
I understand multimaps are key ordered. I have no problems with ints but when I put my char arrays in they are not alphabetically ordered. I must use char array and not <string>. Is it possible to alphabetically order them with char*
39 int c; 40 User *user; 41 char nameH[200]; 42 char line[200]; 43 int ageH; 44 double wH;
I'm trying to finish this project which is supposed to read two files, and merge them alphabetically. I've written this code, and it compiles. But it isn't actually doing anything??The console opens and closes immediately upon running.
Code: #include <iostream> #include <fstream> #include <cstdlib> #include <string> using namespace std; #define hisFamily "The Adopted.txt" //His family #define herFamily "The Originals.txt" //Her family #define ourFamily "The Big Picture.txt" //Our family
I'm trying to arrange names alphabetically from a text file. Inside my textfile, it's like : "John", "Edward", "Peaches", "Anna"... etc.(It has thousand more names, all with quotations, separated by comma and I think it's not typed line by line... but using only one line). How can I read each name separately?
this code, it works if the text file contains names separated by lines and without commas and quotations. I do not know with the case I've stated above.
string numbers[1000]; string line; string number; string y; string x; int z = 1; ifstream myfile; myfile.open("names.txt");
[Code]...
This only shows the data inside text file. I'm new in c++.
is this correct? I used this sorting with numbers i don't know if it is the same with strings. When I run it, there are no errors detected, but when i try to view it, the inputs does not appear.