Alphabetizing names using specific directives

C++ (using dev C++) I am not allowed to use the directives other than #include <iostream> <cmath> <iomanip> and <string>
My class is having trouble with an assignment and none of us can figure out what to do.
I have started the program as follows:
include <iomanip>
include <string>
using namespace std;
int main()
int NUM_STUDENTS, MAX = 25, MIN = 1; string NAME;
cout << "How many students? Must be one student to twenty-five.\n";

while (NUM_STUDENTS < 1 || NUM_STUDENTS > 25)
cout << "Error! Please enter a valid number that is 1 - 25\n ";
I also coded using and for statement asking the user for the names of however many they inputted but I don't want to post that in fear of my teacher thinking I copy and pasted my program off of here (because he doesn't know it's actually me asking the question) I assume I have to assign a number for each student given, but I don't understand how. Like what do I use to alphabetize the names? There's a catch though. I can only output the first person on the list and the last person on the list. Please help! We are dying over here and our teacher is useless.

Also we have not gotten to arrays or anything
Last edited on
I think would be of great assistance. All you have to do is check the first letter of each string (if you treat each string as if it were a character array, just check the value of str[0] for whether it matches what you are looking for, assuming str is a string). If it is less than the one next to it, leave it there. If not, switch the two (should be easy to accomplish with either a temp variable or bitwise XOR assessment). At that point, they'll be sorted by first letter. Just go through again for the second, third, fourth, and so on, up until the length of the string itself (str.length).
Topic archived. No new replies allowed.