C++ :: How To Store Data By Descending Order Auto
Oct 27, 2014
I wanna store my data by descending order auto without doing a classification after , i have come up with a code but it crashes.
Code:
void list::create(int num) {
struct node * n,*temp;
n=new node;
n->data=num;
if(head==NULL)
[Code]....
I don't wanna use the list library with the push.buck, i need to do it by coding it without fix functions ....
View 3 Replies
ADVERTISEMENT
Jan 22, 2014
so my program reads a file type which looks like this...
Michelle 71
Marcie 99
David 42
Rebecca 83
Jonathan 79
Matthew 77
Rose 7
Melanie 75
Kimberly 73
Roger 74
Scott 76
Bradley 77
Drextell 10
Heidi 70
Alan 68
Pearl 13
Jeanne 43
Heber 55
Here is whats in the header of the class
class StudentStat {
private:
int Size;
[Code].....
So as of right now the names are stored in a Names string array and the scores are saved in a Score int array. So my question is where do I begin with my bubble sort? I need it to put the scores in descending order so from greatest score to lowest but I need the Names in the string array to still be connected to the number from the list. Never done a bubble sort before so not sure where to begin.
View 1 Replies
View Related
Nov 9, 2014
I have to put these numbers in ascending and descending order . The interesting point of the function is that sortMe does NOT re-arrange elements in the array; instead, it uses a second array, an array of indexes for the elements in the original array and then sortMe sorts the second array based on the values in the original array. A sorted version of the original array can then be produced with these sorted indexes. I'm not sure why the function is working, even though I called it in main.
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
void sortMe(int array[], int sortedIndexes[], int size, char mode);
char option;
const int SIZE = 5;
[Code] .....
View 7 Replies
View Related
Feb 1, 2014
I'm stuck again on a homework problem. I enter 9 8 7 6 5 4 3 2 1 in to the program when it asks me to. I print out the array (just before the bubble sort routine) and I get the numbers in descending order just as expected. So going into bubble sort routine, the numbers are correct.
I should get 1 2 3 4 5 6 7 8 9 as output.
But I get 1 2 3 4 4 5 6 7 8
Code:
#include <stdio.h>
#include <stdlib.h>
int main() {
int max_size = 20; // max size of array of numbers
int numbers[max_size]; // array for numbers
[Code] .....
View 4 Replies
View Related
Sep 7, 2014
What kind of code should i use for sorting numbers in both ascending and descending order? I don't know how to use bubble sorting either, is there another easy way to sort this out?
View 3 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
Jan 8, 2013
Assignment:
1. Choose what to enter NUMBER or LETTER.
2. Choose type of sorting ASCENDING or DESCENDING.
#include<iostream.h>
#include<conio.h>
main() {
int x,y,z;
cout<<"choose Number or letter
1.number
2.Letter";
[Code] ....
View 9 Replies
View Related
Apr 9, 2014
//Build a program that uses a single-dimension array to store 10 names input by a user.
//After inputting the names, the user should see a menu with two options to sort and print the 10 names in ascending or descending order.
insert
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(){
char names[10];
char temp[10];
int count,i,j;
int sort;
[Code] .....
View 10 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
Feb 16, 2012
This code is for (hospital management system).
This code allow you to add patients.
There are two types of patients. which is:
1. Normal patient.
2. Critically ill patient.
once you added any patient. You will be able to show all patient using "ShowAllPatient;" method. -> i want the Auto-increment ID Number to appear for each patient has been added.
And you will be able to call a patient to provide a hospital services for him/her using "GetNextPatient;" method.
I need to generate an Auto-increment Number for each (patient) has been added. (Auto-increment Number) but it just should be different for each patient. For example the first patient will have 1, The second patient will have 2. etc. The Auto-increment number should appear for each patient.
View 14 Replies
View Related
Dec 6, 2013
I need to find inverse of a matrix data in binary file should be used to form matrix.its not finding inverse correctly rest is working good.
Code:
#include <stdio.h>
void createbin();
void display();
void inverse();
int main()
{
createbin();
display();
inverse();
[Code] ....
View 4 Replies
View Related
Jul 10, 2013
I have written the following code to add data to text files which are required to store 3D scan data (I have to calculate the y-coordinate). My code seems to work except that it stops working when I want to create more than ten text files i.e. the directory I am trying to store them in will not hold any more than ten text files. Code is shown below.
#include <string>
#include <locale>
#include <iomanip>
#include <iostream>
#include <fstream>
#include <sstream>
using namespace std;
[Code] ....
View 1 Replies
View Related
Jun 14, 2013
The program should store a character array in reverse order then display the reversed array. I have also included in the code that will display the actual characters into the array as it loops through. So I know the characters are being stored, but why doesn't it display the entire string when I call it?
Code:
#include<stdio.h>
int main(){
char str[50];
char rev[50];
printf("Enter Desired Text: ");
scanf ("%[^
[Code] ....
Is it just my compiler?
View 5 Replies
View Related
Jul 8, 2013
struct Book{
string bookTitle;
string ISBN;
string author;
string publisher;
string dateAdded;
int qty;
double wholesale;
double retail;
};
What's the best way to store multiple of the above structure?Ideally, it would be with a binary output, but that isn't possible with the strings, unless I'm missing something. So that leaves me with two options.
-Create a second structure that has an outrageous char[] length, and then copy the data from the original structure to write/read to/from the file. The flaws I see in this is excess runtime with copying, and a larger amount of memory is temporarily needed. The positive I see is I can use binary output, which is easier.
-The second option is to just use an ASCII file, and put each element on it's own line, and then just use getline to read each line. The flaw I see in this is that I have to read the file into the structure, instead of just reading the structure and the file can be tampered with (Not a huge concern). The positive is the lack of negative from the above.
View 4 Replies
View Related
Sep 24, 2013
The next step for my project is to take data from a file, and create a new file with the same data, but in reverse order. If a file has the following values:
1
2
3
4
5
The program should create a new file with the following values:
5
4
3
2
1
Seems pretty straight forward, yet I am hitting a snag when I try to compile my program:
Code:
#include <stdio.h>
#include <assert.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
[Code] ....
The following errors occur when I try to compile the fore mentioned code:
intrev.c: In function 'main':
intrev.c:25: warning: unused variable 'out'
intrev.c: At top level:
intrev.c:39: error: expected identifier or '(' before 'while'
[Code] .....
Now I am not concerned with "unused variable 'out'" as it is used, just in a for loop. Is this a problem?
I'm not entirely sure why it's giving me the error at line 39. I've gone over this a couple times and it doesn't look like I've missed any methods which need to be closed. Maybe I've missed something?
I'm also not sure why I am getting an error when I try to close the opened files. I've done this before in the same manner, but without errors. Not sure why I am now, but my guess is that it has something to do with the error on line 39.
View 5 Replies
View Related
May 19, 2014
How data actually store in the File. Like do data store just in one line or at different places for example in array data store in adjacent memory block while in struct data store at different memory block.?
View 2 Replies
View Related
Mar 25, 2013
start writing a program to store some information and then have it recalled. I would like to be able to store a list of the video games I own because i thought it would be fun :)
View 1 Replies
View Related
Apr 18, 2013
How can I store this data into an array?And I only can read the first integer.. 10.... How can I read the whole file...Heres the data:
10 alice 4/23/1972 123-45-6789 support assistant
3 bob 6/7/1980 111-12-1134 logistics manager
1 carol 10/2/1963 987-123-1143 admin ceo
2 dave 10/3/1974 902-22-8914 admin cfo
17 erin 6/13/1991 126-83-1942 technology supervisor
15 frank 2/22/1987 303-12-1122 logistics assistant
Heres what I have so far?
#include <iostream> //Accesses libaries for console input and output
#include <fstream> //Needed to access the fstream object to read files
#include <string> //Needed to access the string class
#include <cstdlib>
[code]....
View 1 Replies
View Related
Oct 24, 2013
I am having problems sorting data... I don't know to to go about it here is my code:
<code>
#include <iostream>
#include <string>
using namespace std;
int main () {
int i;
struct person
[Code] ....
i want to sort it out so that it can output names and ages in ascending order.
View 2 Replies
View Related
Mar 22, 2013
I have this data store into a data structure.
i j x y w h w*h
0 0 0 0 9 11 99
1 0 0 11 9 10 90
2 0 0 21 9 11 99
0 1 9 0 8 12 96
1 1 9 12 8 7 56
2 1 9 19 8 6 48
[Code]...
Code:
struct data {
//Here
/*! horizontal position */
int x;
/*! vertical position */
int y;
/*! width */
int w;
/
[Code]...
data and then i have an array /*! it contain group_id of each data line*/ int group_id[16]={0,0,0,0,3,3,1,1,1,3,3,2,2,2,2,1}; I never worked with 2D array before. My problem is that i want to create a 2D array of that data for example if i write data[j][i].. It will give me the reference/value of all data lines that belongs to j column, and same with group_id[j][i]. I don't know how i can store these structure vaules in this like 2D array.
View 2 Replies
View Related
Feb 10, 2013
I'm having trouble understanding on how to actually store into a container from another class. Any simple example.
View 9 Replies
View Related
Aug 20, 2014
I have a class I use to store column data read from delimited text files.
Code:
class column_data {
// class functions here
public:
// initialize class members
column_data()
: header(""),
[Code] ....
Each column is read into the vector of string. Next the string data is copy converted to the vector of double or the vector of int depending on the data type. There can also be additional transformations of the data (normalization, scaling, etc) and the transformed data is copied to the transformed_double_data vector. I do end up with multiple copies of the data, but I can clear some of the vectors if I don't need all the versions of the data anymore. Each column object goes into a container like a vector of objects or map of objects depending on how I need to access the column data.
There are functions that calculate statistics on the data in the columns and the results are assigned to the object variables like validate_r2. There are separate statistics for each column, so it seems logical to store the results in the column object. This works well for statistics like validate_r2 (pearson's correlation coefficient).
The current issue is that I have other statistics like "pw50" that I need to calculate and store. The statistic is the percent within +/- 50 units and the request for pw50 is passed in from the command line. The issue is that there could be several of these and they can have more or less any value like, pw50, pw75, pw100, etc. Storing data like this doesn't fit into my scheme very well because I can't pre-declare a variable to hold the result for every possible option. I don't know in advance how many, if any, of these there will be. I was thinking of adding two vectors, one of string and one of double,
Code:
class column_data {
public:
// initialize class members
column_data()
: header(""),
type(""),
use(""),
validate_r2(0.0),
[Code] ....
For each of this type of statistic requested, I would push_back a label into the string vector and then put the result into the parallel position in the double vector. This seems like I would work, but there are probably some things that could be done with pointers that might be better. Another option would be a vector of objects where each object had a string value for the label and a double for the result. That would be more bullet proof as far as keeping the label and value together, but I have not ever nested objects in a class like that so I thought I would post. I don't know the syntax for declaring an object of class_b inside the definition of class_a. The need is to provide dynamic storage for an unspecified number of these statistics and a reliable way to retrieve the values using the label.
View 1 Replies
View Related
Jun 15, 2013
How I would store all the data. Also how would I access it after I store it. Side Note we are not allowed to use structures or objects.
For the purposes of this gradebook you should first provide a menu with the following options
-Add a new course Add a new student to a course Add grades for a student in a course Print a list of all grades for a student in a course Print a list of all students in a course Compute the average for a student in a course Compute the average for a course Store Gradebook (to a disk file) Load Gradebook (from a disk file)
-Each of these menu items should correspond to a function you will write.
-For the basic program each student will be represented by an ID number And each course by a course number
-Grades will be whole numbers only (no fractional part)
As indicated in the menu you will need to store and load using a disk file so that the data is retained.
Here are so limiting values in defining your data structures: Maximum Number of students (total) 100 Max number of courses 25 Max number of courses per student 4 Max number of grades per student per course 10
View 6 Replies
View Related
Mar 10, 2015
That;s what i have so far: problem: the output data is not correct.
input file
1301 105515018 "Boatswain" "Michael R." CSE 230 ="R01"
1301 103993269 "Castille" "Michael Jr" CSE 230 ="R03"
1301 103993267 "Castille" "Janice" CSE 230 ="R03"
[Code]....
View 1 Replies
View Related
Oct 23, 2014
I serialize a XML file, and i have this values here:
public class ServiceConfig {
public List<DatabaseDescriptor> Databases { get; set; }
} public class DatabaseDescriptor {
[XmlElement("Name")]
[Code] ....
I have a form1 which is a datagrid view and get's updated like this:
dataGridView1.DataSource = xmlData.Databases;
Now i have a button: get tables, and it opens up form 2, there it's supposed to appear all the tables of the selected Database, when i click on the row i get the database name so i get all the list of Tables from
DatabaseDescriptor
where
DatabaseDescriptor.Name == name
(I get this when i select the row)
But then on the 2nd form, i also have 2 textbox so i add a new table, i add the tablename and id. the new value should appear in the datagridview of the tables, and when i close it and reopen it, it should be there. Maybe i should concatenate first the values or something, how do i do?
View 3 Replies
View Related
Oct 17, 2014
i need to create a new integer data type called BigInt to store a big big integer, which includes Dint(8 bytes) and Qint(16 bytes)
here is the hint/
typedef struct BigInt {
Int data[2];
}
How can i "scanf" and "printf" them????
void ScanBigInt(const char *format, BigInt &x)
if format is “%dd” -> input Dint, if format is “%qd”--> input Qint
void PrintBigInt(const char *format, BigInt x)
View 3 Replies
View Related