Category : sorting

Probably super easy fix, but I’ve been stuck for hours now. I am "translating" this the code below to an identical function (Results wise) but it must use indexes and brackets instead. I’ve done insertSort before, but the assignments specifically states that I have to "translate". // This is the code I am "translating" void ..

Read more

write a program that keeps track of student progress in a course. In particular, your program prompts the user to enter the number of students in the course. Then, your program prompts the user to enter the first and last names of each student and marks obtained. Your program displays the first names, Last names, ..

Read more

I saw this answer. https://stackoverflow.com/a/47317853/8106257 But, I don’t satisfying logical const. Is there any other way to sort custom class object with const member variable? I was firstly thought that how about using move constructor but it didn’t work. #include <iostream> #include <vector> #include <algorithm> class City { private: const int _cost; const int _customer; ..

Read more

can you please tell me where I have got it wrong. Help me in learning I don’t know if the code is correct class Solution{ public: vector sortArr(vectorarr, int n){ for(int i=0;i<=arr.size()-2;i++){ int small=i+1; for(int j=i+1;j<=arr.size()-1;j++){ if(arr[j]<arr[i+1]) small=j; } if(arr[i]>arr[small]) swap(arr[i],arr[small]); } return arr; } }; Source: Windows Que..

Read more