C++ :: Sort Players In Descending Order On The Basis Of Score - Program Not Working Properly

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


ADVERTISEMENT

C :: Write Program To Sort 2 Ints On Ascending / Descending Order?

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

C++ :: Bubble Sort - Put In Descending Order

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

C :: Bubble Sort - Output In Descending Order

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

C++ :: Enter Number Or Letter And Sort In Ascending Or Descending Order

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

C :: Insertion Sort In Ascending Order Not Working

Jun 20, 2014

I am having trouble sorting out a list of names in c. I have code for sorting the names, but when I go to print them out they still are in the same order as they were at the beginning so something isnt right. So the function that I need is the sort_data function.

Code:
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#define MAX_STRING_LEN 25
void insert_data(char **strings, const char* filename, int size);
void allocate(char ***strings, int size);

[Code] ....

The list that I am reading in is as follows:

matt
susan
mark
david
aden
phil
erik
john
caden
mycah

So I need to get this list in alphabetical order, but when I run my code and print out this list after I run the sort function, they are still in this order.

View 5 Replies View Related

C++ :: Video Game - Compare 3 Players Score And Output Highest

Oct 21, 2013

I was tasked with creating a program that asks for the scores of three gamers then takes these scores and outputs the highest. I THINK I have the other parts down but I don't know how to get the program to compare the scores and output the highest without having to write a long list of commands comparing playerone to playertwo, then player one to playerthree, then player two to playerone, etc.

#include <iostream>
using namespace std;
int main () {
int playerOne, playerTwo, playerThree;
cout << "Please enter score for Player One: ";
cin >> playerOne;

[Code] .....

View 10 Replies View Related

Visual C++ :: Number Of Players - Making Score Stay With Each Player

Oct 21, 2013

I am writing a game that is 2 to 4 players. i am wondering how to ask how many players, and make the score stay with each player. it is a rip off of zombie dice, this is what i have so far the playerScore array is to hold the score for each player and the turn array is hold hold the values that they rolled that turn, i also dont know how to clear out the turn array when it goes to the next player.

#include <iostream>
#include <cstdlib>
#include <cmath>
#include <ctime>
using namespace std;
int main() {
int playerScore[4];

[Code] ....

View 3 Replies View Related

C++ :: Count Function In Program Not Working Properly - Counting Blank Nodes

May 9, 2013

I tested my count funtion. So my count function is not working properly, it should return 5 because 5 words have prefix "tal," but it is giving me 10. It's counting blank nodes.

This is my main.cpp file

int main() {
string word;
cout<<"Enter a word"<<endl;
cin >> word;
string filename;

[Code] .....

View 9 Replies View Related

C/C++ :: Put Numbers In Ascending / Descending Order

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

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 View Related

C++ :: Sorting Numbers In Both Ascending And Descending Order?

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

C :: Sorting Array Alphabetically - Print 10 Names In Ascending Or Descending Order

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

C :: String As Parameter Not Working Properly

Oct 19, 2013

I want to alter a string inside a function, but it is not working.Here is the function:

Code:

#include <stdio.h>
void test (char *ch){
ch[0] = 0;
ch[1] = 1;
ch[2] = '';
}

[code]...

View 2 Replies View Related

C/C++ :: Right Hand Maze Not Working Properly

Nov 1, 2014

I am creating a right hand maze solution, and it actually works for the most part, but it gets stuck at the sixth spot and will not proceed any further. I cannot seem to find my error even though I know it's probably a small one in my code, here is what I have at the moment:

#include "stdafx.h"
#include <iostream>
#include <Windows.h>

[Code].....

View 6 Replies View Related

Visual C++ :: Slider Not Working Properly In A Dialog MFC?

Jul 3, 2013

I have a slider control on a dialog box. I am playing a video file and slider moves according to the video elapsed. Suppose I have set the slider range to 100. Now till some point say 90, the slider moves to the point wherever I click the mouse. but at the last point in between some range say 90 - 100 (to the end of the slider), if I click the mouse button anywhere, slider jumps to the end.

I am using a TimeLine control where user can add more than 1 video (1, 2, 4, 8, 10 , 50 etc......), If I use only one video, slider moves as per the video progression.....Issue arises when I add more than 1 video and click on the start button, slider starts moving....Now when I drag the slider to any position or I click the mouse button anywhere on the slider control, slider thumb moves to that position and immediately jumps back to some other position. This is the Issue, I am facing.

share some sample code where slider is moving with the video showing the progress of the video.

I want to implement a functionality similar to VLC player. Wherever user clicks the mouse, slider moves to that point.

View 13 Replies View Related

C++ :: Using Array To Accept 10 Test Score - Print Highest / Lowest And In Reverse Order

Jan 28, 2014

Using the array to accept 10 testscore. Calculate and print the highest, lowest, fifth test score entered and all the test score entered in reverse order.

How i would get it to print the highest,and lowest and in reverse order. I'm confused as to what to do...

View 4 Replies View Related

C++ :: Get Scores From Admin And Sort Them Ascending Then Show Middle Score

Nov 23, 2013

I program a software to get scores from admin and sort them ascending then show the middle score(if admin enter middle).but when i compile it nothing happen.what should i do?here's code ,i use dev compiler

Code:
#include <cstdlib>
#include <iostream>
#include <math.h>
#include <string.h>
using namespace std;
int main(int argc, char *argv[]) {
int counter,j,count,counter2,m;

[Code] ....

View 14 Replies View Related

C :: Program That Queries User For A Noun And Forms Its Plural On The Basis Of Rules

Nov 13, 2014

I am having trouble with a program that queries the user for a noun and forms its plural on the basis of these rules:

a. If the noun ends in "y" remove the "y" and add "ies".
b. If the noun ends in "s", "ch", or "sh" add "es".
c. In all other cases, add "s".

I am having trouble getting started.

View 4 Replies View Related

C :: Snakes And Ladder Program - Dice Function To Switch Between Players

Mar 25, 2013

I am writing a snakes and ladder program and I'm almost finished, but I am struggling with the dice to work in the way I want it to work. I want the dice to work like this :

Before each player throw the dice they must start at 0.
Each player must throw a 6 on the dice to move on the board.
If a player threw a 6 on the dice, that player can throw again.

But I ended up with two seperate dice, one for each player (game is only for two players).And when I run the program, both players don't start at 0. And when I throw the dice, both players move at the same time but with different values.

If one of my players threw a 6, they just keep on throwing until someone wins the game. I tried to use a switch and if statements but I couldn't get it right. And so I did this :

Code:
#include<stdio.h>
#include<stdlib.h>
#include<windows.h>
#define SpaceBar 32// 32 is an ASCII value for a spacebar

[Code] ....

View 5 Replies View Related

C++ :: Program To Search Soccer Players Data To Check Whether Name Supplied By User Is On That List

Oct 29, 2014

Write a program that will search soccer players data to check whether a name supplied by the user is on that list. For doing the search, the user may provide either the player’s full last name or one or more starting letters of the last name. If a matching last name is found, the program will display the player’s full name and date of birth. Otherwise, it will display “Not found”.

Requirements specification:At the start, the program will ask the user to enter information about 10 soccer players constituting soccer player data. Each soccer player data will consist of the following fields:

Last name
First name
Birth month
Birth day
Birth year

The user will be asked to enter each soccer player data on a separate line with the field values separated by a space.

Once the data is entered, the program will display a menu of choices as below:

Chose an option:

(1 – input data, 2 – display original data, 3 – sort data , 4 – display sorted data 5 – search by last name 6 – exit the program )

If the user chooses option 1, the program will ask the user for a data and populate the array of structures that will hold the data for each of the soccer players.

If the user chooses option 2, the program will display data in the order provided by the user (original data).

If use chooses option 3, the program will sort data by last name.

If user chooses number 4 the program will display the data sorted by last name.

If the user chooses option 5, the program will ask the user to enter one or more starting letters of the soccer player’s last name. It will then search the soccer player data for the matching last name. If a match is found, it will display the first player found with the matching pattern. If a match is not found, the program will display “Not found”. If the user enters two forward slashes (//) for the last name, it will no longer search for the name. Instead it will display the main option menu.

If the user chooses option 6, the program will display “Thank you for using this program” and will end.

Why my program isint executing correctly. Here is what i've so far . . . .

#include <iostream>
#include <string>
using namespace std;
struct data {
string lname;
string fname;
int birthmonth;
int birthday;
int birthyear;

[Code]...

View 3 Replies View Related

C++ :: Program That Takes Baseball Players Statistics And Display Averages - Function Division

Oct 10, 2013

I was required to write a program that takes a baseball players statistics and displays there averages. I was required to make 3 function in the file to perform this tasks. my problem I am having a division problem in the SLG function. My compiler does not require the system ("PAUSE"); command.

OUTPUT
The player's batting average is: 0.347
The player's on-base percentage is: 0.375
The player's slugging percentage is:
(test)AB = 101
(test)Tot Base = 58
0.000

Code:
/* Batting Average Program
file: batavg1CPP.cpp
Glossary of abbreviations:
BA = batting average
PA = plate appearances
H = hits
BB = bases on balls (walks)

[Code] ....

View 3 Replies View Related

C# :: Sort In Ascending Order?

Mar 10, 2015

i have a list

ID | Location | Quantity
1 | 2 | 5
2 | 3 | 10
3 | 4 | 8

i want the order to be in ascending order by Quantity so it should produce this

ID | Location | Quantity
1 | 2 | 5
3 | 4 | 8
2 | 3 | 10

View 4 Replies View Related

C :: Sort Matrix Such That It Has Value In Ascending Order

Sep 29, 2013

Trying to sort matrix such that it has value in ascending order.

But outcome is coming :

Code:
Matrix after sorting :
2,2,2,2,
2,2,2,2,
2,2,2,2,
2,2,2,2,
Can't find whats wrong.

[Code]....

View 2 Replies View Related

C :: Sort Numbers In Order In Programming

Feb 19, 2014

Write a program that orders three double numbers by increasing value. The program should include a function named sort3 that takes three double * arguments (pointer to double). The function prototype is void sort3(double *x, double *y, double *z); The function should reorder the values pointed to by its arguments so that after the call sort3(&x, &y, &z); the numbers satisfy . Your program should input data and print results using the following format:

Enter three numbers: 4.7 1.4 3.2
The ordered sequence is: 1.4 3.2 4.7

And here is my program: C code - 32 lines - codepad

I am getting a lot of errors when I run it through GCC. I can only use pointers.

View 4 Replies View Related

C :: Sort Array And Save New Order Of Elements

Sep 25, 2014

So I try to sort an array with qsort and then save the new order, so this means if I have a list like:

4 3 7 2
[0] [1] [2] [3],

after sorting it becomes:

2 3 4 7
[3] [1] [0] [2] <== this is what I want to have!

Code:

void qsort_my(int *a, int l, int r, int *array_order) {
int j;
if( l < r ) {
j = split( a, l, r, array_order);
qsort_my( a, l, j-1, array_order);
qsort_my( a, j+1, r, array_order);

[Code]...

But my problem is that the list gets sorted, but the indexes do strange stuff. When I run with this list:

4 8 14 1 2 1 22 12 2 14
Pos: 0 1 2 3 4 5 6 7 8 9

I get:

1 1 2 2 4 8 12 14 14 22
Pos: 1 0 1 0 0 5 7 6 5 6

And with some printfs I noticed, the first two calls of split it is fine but then strange things start to happen, what I do wrong?

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved