User Profile

Collapse

Profile Sidebar

Collapse
xtheendx
xtheendx
Last Activity: Jun 3 '08, 04:14 PM
Joined: Apr 30 '08
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • xtheendx
    replied to Sorting Multiple Vectors
    in C
    how would I use the map and pair in my code. I have never heard fo them. sorry if it is dumb question, but do i leave it how you wrote it or should i plud in my variable names... also is their a special #include i should use? thanks for the help....
    See more | Go to post

    Leave a comment:


  • xtheendx
    started a topic Sorting Multiple Vectors
    in C

    Sorting Multiple Vectors

    In my program i have three sperate vectors that store the students last name, first and score. I need to sort it by last name and print the contents of the vectors lastname, firstname: score. Well i have got it doing that for the most part. But after it sorts the lastnames the first names and scores are still in the same postion in their vectors, so when it prints the reults the last names are with the wrong first name and score. any ideas? ...
    See more | Go to post

  • now the user can enter all the info indivudally. And it the sort works... the problem i run into now is that for some reason when it prints it always priints two zeros before the text. and while it sorts the last names it prints the last name that is sorted withe first name and score of the first entry. ex. user inputs
    studnt 1 last name: oaks
    student 1 first name: john
    student 1 grade: 100

    studnt 2 last name:...
    See more | Go to post

    Leave a comment:


  • hey man thanks that worked wonders. I have edited the code and it does run smoother and doesnt crash. The problem i run into now is that when i run it last name and first name are displayed at the same time for the user to enter. Like this last name: first name:. How get them to be seperate so the user can enter them individually. Also it not sorting them but i think it has to do with the program not getting the first and last name seperatly....
    See more | Go to post

    Leave a comment:


  • I understand the problem in the example you gave. Becasue numbers[0] = 50 that when the for loop tries to call numbers[1] there is nothing there, even though the condition is true....wait are you saying that when i am setting myy for loop to i <= numStudents, that when it gets to that last element there is nothing there because the vector starts at 0 and numstudents starts at 1. so i would set the for loop to i <= numStudents -1. that makes...
    See more | Go to post

    Leave a comment:


  • Alright i think i just had a revalation. i realized what you were saying about i < numStudents. I need to set it up so i is less than or equal to the size of the vector. so this is how i changed my code... and it worked it printed the names in alphbetical order.
    Code:
     void students::getData()
    {
    	int numStudents;
    	vector<string> student_names(numStudents);
    	
    	cout <<"Enter number of students to
    ...
    See more | Go to post

    Leave a comment:


  • Alright on the first one the for loop is only ran through once when i=0, after that i = 1 and and so is numItems. So i see why that is wrong, but in my code i have declared int numStudents and then let the user define the number of students. So in my for loop i shouldn't have that problem...at least that is what i think.

    And for the second questions on the codes you wrote, on all three of them you haven't declared i. But in my...
    See more | Go to post

    Leave a comment:


  • the only problem i can see is that your just print the 0 space in the numbers array. So i am guessing that is what i am doing in my code..calling it to output nothing. and as far as being sure about i=0; i < numStudents; i++...i am pretty sure because that would call each array element 0 thorugh the size of array. right? i appreciate your method of help...i don't like being told the answer. thanks...
    See more | Go to post

    Leave a comment:


  • I'm sorry that is not what i have meant to do...I just wanted suggestions and i got some that helped alot.. like the idea of using strings, so now i am using string vectors and completly redid my program. I do appreicate your guys help and sorry if came off stupid...i was just really lost.. it being my first large program and all. Here is what i have now as sort of prototype using the vectors. I can get it to read the names i eneter, but for some...
    See more | Go to post

    Leave a comment:


  • thanks for the help man, i got rid of all the errors and the program "runs' now. When it runs it just prints out getData() cout stuff 100 times, and then prints out Student Last name: folloed by a bunch of jibberish. The program requirments call for the program to promt the user for the number of students they would like to enter, that is the only reason i did it like that. I have commened out the bubble sort, becaussei can't figure out how...
    See more | Go to post

    Leave a comment:


  • Grade book program using arrays and Bubble sort (many problems)

    I am writing a gradbook type program. It first allows the user to enter the number of students they want to enter. then allows them to enter the first name, last name, and grade of each student. The program then should sort the names alphabetically by last name and display a list of all the students names and grades in alphabetical order. I have completed all my functions and classes, but i am getting a god aweful amount of errors and i am not sure...
    See more | Go to post
No activity results to display
Show More
Working...