473,396 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

C++ Sorting And Displaying

5
im using the bubble sort but i need to display it. how would i do this


// This program Enter test scores and sort them in oder and Averages them

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
double *score, total = 0, average;
int TestScores, count;


cout << "How many Test Scroes do you wish to enter ";
cin >> TestScores;
score = new double[TestScores]; // Allocate memory

// Get the Test Scores
cout << "Enter each students test scores.\n";
for (count = 0; count < TestScores; count++)
{
cout << "Student " << (count + 1) << ": ";
cin >> score[count];
}

//bubble sort
for (int i=0; i<TestScores; ++i)
for (int j=i; j<TestScores; ++j)
if (score[i] < score[j])
{
double tmpscore = score[i];
score[i] = score[j];
score[j] = tmpscore;


}



// Calculate the total Scores
for (count = 0; count < TestScores; count++)
{
total += score[count];
}

// Calculate the average Test Scores
average = total / TestScores;

// Display the results
cout << fixed << showpoint << setprecision(2);

cout << "Average Score: " << average << endl;


// Free dynamically allocated memory
delete [] score;

return 0;
}
Apr 13 '06 #1
0 4242

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Ross | last post by:
The following codes originally provided by a kind responder Toby A Inkster in another newsgroup for working on displaying a table on web capable of sorting are modified by me (a newbie). How to...
2
by: DelphiBlue | last post by:
I have a Nested Datagrid that is using a data relations to tie the parent child datagrids together. All is working well with the display but I am having some issues trying to sort the child...
2
by: Alan Searle | last post by:
I find that I can display structured data very nicely using XML with an XSL template. As an extra 'goodie', I would like to give users the ability to sort that data (for example with a button...
2
by: DelphiBlue | last post by:
I have a Nested Datagrid that is using a data relations to tie the parent child datagrids together. All is working well with the display but I am having some issues trying to sort the child...
1
by: Nate | last post by:
I have a GridView with one sort column. When I click the sort column the first time nothing happens. After that when I click the sort column the sort order changes and my grid is updated as...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.