Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Debug#3 #include #include using namespace std; struct test { string name; double score; }; //void sort(test*, int); void sort(test a[], int number); int main() {

Debug#3

#include #include using namespace std;

struct test { string name; double score; };

//void sort(test*, int); void sort(test a[], int number);

int main() { test* scores = nullptr; int classSize; cout << "How manys students took the test." << endl; cin >> classSize; scores = new test[classSize]; test* p = scores;

while () { cout << "Enter the name of the student" << endl; cin >> scores->name; cout << "Enter " << scores->name << "'s score" << endl; cin >> scores->score; scores++; } while () { cout << scores->name << " " << scores->score << endl; scores++;

} while () { cout << "Boo" << endl; cout << scores->name << " got a " << scores->score << endl; scores++; } delete []scores; scores = nullptr;

system("pause"); }

void sort(test* score, int size) { cout << "hello" << endl; int startScan, minIndex; double minValue;

for (startScan = 0; startScan < (size - 1); startScan++) { minIndex = startScan; minValue = score[startScan].score;

for (int index = startScan + 1; index < size; index++) { if (score[index].score < minValue) { minValue = score[index].score; minIndex = index; } }

score[minIndex].score = score[startScan].score; score[startScan].score = minValue;

} } /*void sort(test a[], int number) { for (int k = number - 1; k >= 1; k--) { // Find maximum of a[0..k] test* maxPointer = a; for (test* p = a + 1; p != a + k + 1; p++) { if (p->score > maxPointer->score) maxPointer = p; } // Swap *maxPointer with a[k] swap(*maxPointer, *(a + k)); } }*/

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Time Series Databases New Ways To Store And Access Data

Authors: Ted Dunning, Ellen Friedman

1st Edition

1491914726, 978-1491914724

More Books

Students also viewed these Databases questions