446,305 Members | 1,614 Online
Need help? Post your question and get tips & solutions from a community of 446,305 IT Pros & Developers. It's quick & easy.

# Matching students to university problem

 P: 40 Hello good friends, please i need your help and advice on how i should best programme the problem, if possible a different option to solve it is welcomed. The problem a matching problem, how to much students to different universities with their choices Each student has a chance to select 6 universities . Each university has limited number of places for the students Some universities demand average grade of students wanting to study there. Some not. This is how i started . Please i want to know whether i am on the right track. Expand|Select|Wrap|Line Numbers #include "stdafx.h" #include using namespace std;   struct universities{       string name;       int places;       int average grade; } university[i];   struct student{     string name;     universities choice[i]; }student[i]     int _tmain(int argc, _TCHAR* argv[])   {     ifstream in;     string filename;     cout <<"give filname";     cin filename;       in.open(filname, c_str());       return 0; }   Thanks alot in advance. Mar 19 '07 #1
97 Replies

 P: 99 well, youre looking good so far. where you go from here really depends on how the final decisions are made on who gets matched with what university . . . your next step is to write an algorithm that takes the input data from your file and then write another algorithm that makes the actual matches between the students and schools. as youve come so far, i would also suggest adding an Expand|Select|Wrap|Line Numbers int my_average_grade;   to the student struct. (since each student presumably has an average grade . . . this is the data being supplied to your decision algortihm.) the algortihms you write for this program depend almost entirely on how the schools (or students) are making the decision of who does where. Mar 19 '07 #2

 P: 40 Hello friends, please i need someone to come to my rescue. I having trying to programme the problem. there n universities and m students with six choices of their favorite university. Each university has a limited number of students they can accomodate. Whereas some universities the selection process is based on average grade of the students, in other universities not. My problem is to write a pr+rogramme to match the students at their various universites. please here is how i tried to solve the problem. I please want some to look through and help me maket the necessary correction. Thanks alot in advance. Expand|Select|Wrap|Line Numbers #include "stdafx.h" #include using namespace std;   struct universities{       string name;       int places;       int average grade; } university[i];   struct student{     string name;     universities choice[i];     int my_average_grade }student[i];         for(int i=0;i> university[i].max average_grade;       universities.university[i]=university.[i].max average_grade;       university[i].places=0;       while(university[i].places>0)       {        for(int i=0;i

 Expert 5K+ P: 5,000 For one thing you are using the same iterative variable about 7 times in your nested loops. You've also declared something called "max average_grade" which is illegal syntactically. And I don't know what you are doing here: Expand|Select|Wrap|Line Numbers universities.university[]=university;   Whatever it is, it isn't doing what you think it should be doing. Mar 19 '07 #4

 P: 40 please i tried to make some changes in the programmme. Would someone please look through for me again? Thanks alot. Expand|Select|Wrap|Line Numbers struct universities{ string name; int places; int average grade; } university[i];   struct student{ string name; universities choice[i]; int my_average_grade }student[i];   double max average_grade=0;       for(int i=0;i> university[i].max average_grade; universities.university[i]=university.[i].max average_grade; university[i].places=0; while(university[i].places>0) { for(int i=0;i

 Expert Mod 100+ P: 2,328 Please post your full question. Our members cannot guess what difficulties you are having by just looking at your code. Make the necessary changes soon. Mar 19 '07 #6

 P: 40 I am trying to write a programme, that should match students to their university of choice.I have a file containing universities and students would selected these universities. Each student has selected six of their prefered university in a preference oder, like first, second, etc in this order. For some universities minimum average grade is required, while others not. The universities have also limited places for the student. The problem ist to matched the students to their various as effficent as possible. My idea ist first lot for the universities by using minimum average grade to select the student , that is what exactly l tried programming. I need some advice and if possible correction in what i programmed. Thanks alot once again. Mar 20 '07 #7

 Expert 2.5K+ P: 3,652 luap, Please do not double post your question. This thread is the third thread you have on the same subject, and I have just deleted a fourth. You only need one thread for this one question - you can keep us up-to-date with what you've tried and what problems you have in this thread, but don't make any additional threads on the same topic. Mar 20 '07 #8

 Expert Mod 2.5K+ P: 4,677 My idea ist first lot for the universities by using minimum average grade to select the student , that is what exactly l tried programming. I need some advice and if possible correction in what i programmed. So what is your question? You posted code, but there is no specific question, or error messages or anything. What do you mean 'advice' - do you need to adhere to good programming practices? Mar 20 '07 #9

 Expert 2.5K+ P: 3,652 Note: Three threads have been merged into this thread - there may be some discontinuity or confusion among posts. Mar 20 '07 #10

 P: 40 I am very sorry for the problem i caused. It is just that i want ot if i am on the right track with what i have programmed so far. I am just a beginner in c++ programming still have to do a lot. please could you please look at my programm to see if i am on the right track: logical representation of the problem and also if i have to make some changes to the programme i have written so far . Once again thanks alot . Mar 20 '07 #11

 P: 40 please i would like to know whether the for loop was as follows. I want to arrang the universities with the highst average grade requirement first. Thanks. Expand|Select|Wrap|Line Numbers  for(int i=0;i

 P: 40 I want to arrange the universities with the highst average grade requirement first Am i on the right track. Thanks. Expand|Select|Wrap|Line Numbers for(int i=0;i

 Expert Mod 2.5K+ P: 4,677 please i would like to know whether the for loop was as follows. I want to arrang the universities with the highst average grade requirement first. Thanks. Expand|Select|Wrap|Line Numbers  for(int i=0;i' instead of the '.'s, but I'm not sure), have you tried plugging that into a compiler? Mar 20 '07 #14

 P: 40 please i would like to know if this is correct. Here i want to select the students using the average scores and places avialable at the universities. Thanks once again Expand|Select|Wrap|Line Numbers for(int i=0;i> university[i].max average_grade;       universities.university[i]=university.[i].max average_grade;       university[i].places=0;       while(university[i].places>0)       {        for(int i=0;i

 P: 99 you should post this as a reply to your original thread . . . simply because your thread is no longer at the top of the list doesnt mean that no one is reading it . . . anyways, have you tried compiling and running your code? i would say that is the first test of whether your solution is correct or not. Mar 20 '07 #16

 100+ P: 2,476 i think u r on the right track ..... but check out the line university[j].average_grade=university[i].average_grade[j] here it would be university[j].average_grade=university[i].average_grade welcome Mar 20 '07 #17

 Expert Mod 2.5K+ P: 4,677 These questions are on the same program and have been merged (and eventually I'll get around to merging them with the merged "original thread" of his...). Mar 20 '07 #18

 Expert 2.5K+ P: 3,652 Too late - I merged them again. Mar 20 '07 #19

 P: 40 Hello nice friends, i am here once again seeking your help. I want to know, how to solve this problem. Expand|Select|Wrap|Line Numbers struct universities{       string name;       int places;       double average_grade;       int akzept; } university[i];   struct student{     string name;     universities choice[i];     double my_average_grade; }student[i];     int _tmain(int argc, _TCHAR* argv[])   {     ifstream in;     string filename;     cout <<"give filname";       in.open(filename, c_str());     {      while (!in.eof())      {        getline(in,filename);        cout << filename <

 P: 99 where are you getting the name of the file to open? Mar 20 '07 #21

 P: 40 From an excel dokument, containing Students with choices of the universities and unversities with their average grades and places avaialible. It is really a big file dokument. Thanks! Mar 20 '07 #22

 P: 99 well, i only ask because it doesnt look like your actually passing the name of the file into the variable filename. Mar 20 '07 #23

 P: 99 are you posting entire snippets of code? . . . i think you would have much better luck with cut and paste than trying to retype your code by hand. and please do use code tags. Mar 20 '07 #24

 P: 40 Hello friends is me once again.Please I will like to know how to bild an arrary for this data structure, without specifying the number of members of the array. That is array for students, array for universities and array for the matching of students and universities. Thanks. Expand|Select|Wrap|Line Numbers struct universities       {       string name;       int places[i];       double average_grade;       int akzept[i];       } university[i];   struct student    {     int id;     universities choice[i];     universities average_grade;     double my_average_grade;    }student[i];   struct matching_student{      universities[i] match;     student[i]matchd;     }matching[i]; Mar 21 '07 #25

 P: 99 i dont think there is a way to initialize a primitive array without declaring how long it is. you might try using a more advanced data type . . . otherwise, the best way to get an array the size you want it without knowing in advance how big it should be is to start with a reasonable guess and then just copy the old array to a new, bigger array if you need it larger. thats a real pain though . . . Mar 21 '07 #26

 P: 40 Thanks, just another quesition. could please tell if this code is correct, if not how schould write it then. Thanks again. Expand|Select|Wrap|Line Numbers   for(int i=0;i> university[j].max_average_grade;       university[i].average_grade=university.[j].max average_grade;         while(university[i].places > 0 && university[i].average_grade)       {        for(int j=0;j

 P: 99 if youre asking me to check your code, the first thing i would do is compile it. (have you compiled your own code?) but in order for me to do that, i need to see your function in some sort of context. for instance, i need to see how you get into this for loop and the declarations and initializations of the variables in it. it would be great to see your main(). (if that is too big, then replace already-verified sections of code with a simple description of what they do.) think of me as a pseudo-instructor. if you handed in just a for loop to your instructor (or whoever else gave you the assignment) when they asked for a whole program, how do you think it would go over? i cant do anything with just a for loop. (and you really do need to try compiling it on your own.) Mar 21 '07 #28

 P: 40 This is what i have done so far. so i please it to you to have a look at it and check for what the problem might be. Thanks again. Expand|Select|Wrap|Line Numbers #include "stdafx.h" #include  #include  #include  using namespace std;       struct universities       {       string name;       int places[i];       double average_grade;       int akzept[i];       } university[i];   struct student    {     int id;     universities choice[i];     universities average_grade;     double my_average_grade;    }student[i];   struct matching_student{      universities[i] match;     student[i]matchd;     }matching[i];     int _tmain(int argc, _TCHAR* argv[])   {     ifstream in;     string filename;     cout <<"give filname";       in.open(filename, c_str());     {      while (!in.eof())      {        getline(in,filename);        cout << filename <> university[j].max_average_grade;       university[i].average_grade=university.[j].max average_grade;         while(university[i].places > 0 && university[i].average_grade)       {        for(int j=0;j

 P: 99 . . . and the problem youre having is??? (well get you to a full post sooner or later ;)) Mar 21 '07 #30

 P: 99 (i see several things wrong with your code. i would love to help, but this is your code, remember. start by compiling your program and taking care of all the errors you recognize. ill help you for as long as you care to post here, but i wont write your code for you - you have to have specific questions. site policy.) Mar 21 '07 #31

 P: 40 My problem is how to get the programme run by the complier. I am really sack up in the head,because could not simply solve the problem. I have trying all day long . so please i just where the problem lies in order to have the problem solve. Maybe i can not put explain my thought in much better way. So please if you have the time just run the code and you may see where the problem lies and give me some advice on some of the changes the programme need to under go. That is my thought how the problem should be solve. My difficulty is the programme language. That is what i am learning now. I hope you please understand, what i mean. Thanks . Mar 21 '07 #32

 P: 40 I have a problem . Whiles compling,my coplier gave the following result :\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(14) : error C2065: 'i' : undeclared identifier c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(28) : error C2337: 'i' : attribute not found can you please figure out what i might have done wrong? Thanks Mar 21 '07 #33

 P: 99 well, 1) it looks like youre still trying to initialize arrays without declaring how long they are. (which, i would bet is the source of the error you just posted) 2) it looks like what youre doing here Expand|Select|Wrap|Line Numbers while (!in.eof()) {     getline(in,filename);     cout << filename <

 100+ P: 1,806 You need to declare i before you use it (although you probably don't need i to initialise the arrays). eg int myArray[]; is sufficient. Secondly you may like to declare your structs individually and then declare array of them eg: Expand|Select|Wrap|Line Numbers struct student {   int id;   universities choice[]; /* Does this need to be an array and is it fixed size? */   universities average_grade;   double my_average_grade; }student;   student theseStudents[];   Mar 21 '07 #35

 P: 40 please i would like to know which form of the declaration is correct. 1. Expand|Select|Wrap|Line Numbers int number[i];      int number[j]; ist this initialisation neccessary for(int i=0;i

 Expert Mod 2.5K+ P: 4,677 Have you tried putting them in a compiler and running them yourself? Mar 21 '07 #37

 P: 99 before you do any of that, you need to properly declare and initialize your data structures. first of all, i think it would probably be easier if you tried not to use arrays in the structs you define. instead, create an array of the structs you define in the body of the program. this way, you will either know know how big the arrays should be (which you do need to know before initializing the arrays and actually storing data in them) or you can at least guess . . . you are also in a better position to grow the array if you find you need to. Mar 21 '07 #38

 P: 40 please i tried to do some changes to my programme. The compiler still can not run it. Here is my code and the compiler results. Expand|Select|Wrap|Line Numbers #include "stdafx.h" #include  #include  using namespace std;         struct universities       {       string name;       int places;       double average_grade;       }university;     struct student  {   int id;   universities choice[6];    universities average_grade;   double my_average_grade; }student;         struct matching_student{      universities[i] match;      student[i]matchd;      }matching;     matching;     int _tmain(int argc, _TCHAR* argv[])   { double max_average_grade   int number[i];   int number[j];   int number[k];   int max_student, student_no;   int max_uni;     universities university[number[i]];   student student[number[j]] ;       for(int number[j]=0;number[i] 0 && university[number[i]].average_grade)       {        for(int number[j]=0;number[i]

 P: 99 Expand|Select|Wrap|Line Numbers int number[i]; int number[j]; int number[k]; . . . do you mean? Expand|Select|Wrap|Line Numbers int i, j, k; i think you should eliminate the number[] completely and just use three ints. that would get you three ints to use . . . i dont think you need an array here. and you still do need to pick an initial size for the arrays you do use. you just simply cannot store values (or retrieve them) from an array that hasnt been initialized to a certain size . . . an array is a fairly limited data type and the compiler does not perform bounds checking on it. this means that if your array is 5 units long and you try writing to the 11th unit, you will be writing to any random memory location that has nothing to do with your array . . . the compiler will not stop you. if youre lucky, your program will crash immediately. worse, it could only slightly corrupt your data and leave you dumbfounded for hours . . . this is why you need to declare how long it will be and stick to accessing only those elements which you have declared. Mar 22 '07 #40

 P: 99 . . . somewhere in main() you need to figure out the length of your arrays. either ask the user to input the number of elements or try something like this: Expand|Select|Wrap|Line Numbers int length = 100; universities university[length]; and then if you find that that array is too small, copy that array to a new, longer array. Mar 22 '07 #41

 P: 40 please after i tried to change my code, hier is changed version. / Expand|Select|Wrap|Line Numbers #include "stdafx.h" #include  #include  using namespace std; typedef max_uni 15; typedef max_student 40;       struct universities       {       string name;       int places;       double average_grade;       }university;     struct student  {   int id;   universities choice[6];    universities average_grade;   double my_average_grade; }student;         struct matching_student{      universities[i] match;      student[i]matchd;      }matching;     matching;     int _tmain(int argc, _TCHAR* argv[])   {   double max_average_grade;   int i, j, k;        int max_student, student_no;   int max_uni;     universities university[max_uni];   student student[max_student] ;       for(int i=0;i<=max_uni;i++)     {        university[i].name=university;     }       for(int j=0;j 0 && university[i].average_grade)       {        for(int j=0;j &std::basic_string<_Elem,_Traits,_Ax>::operator =(const std::basic_string<_Elem,_Traits,_Ax> &)'         with         [             _Elem=char,             _Traits=std::char_traits,             _Ax=std::allocator         ]         c:\programme\microsoft visual studio 8\vc\include\xstring(880): or 'std::basic_string<_Elem,_Traits,_Ax> &std::basic_string<_Elem,_Traits,_Ax>::operator =(const _Elem *)'         with         [             _Elem=char,             _Traits=std::char_traits,             _Ax=std::allocator         ]         c:\programme\microsoft visual studio 8\vc\include\xstring(885): or 'std::basic_string<_Elem,_Traits,_Ax> &std::basic_string<_Elem,_Traits,_Ax>::operator =(_Elem)'         with         [             _Elem=char,             _Traits=std::char_traits,             _Ax=std::allocator         ]         while trying to match the argument list '(std::string, universities [])' c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(60) : error C2676: binary '[' : 'student' does not define this operator or a conversion to a type acceptable to the predefined operator c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(60) : error C2228: left of '.id' must have class/struct/union c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(91) : error C2228: left of '._uni' must have class/struct/union c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(97) : error C2039: 'max_average_grade' : is not a member of 'universities'         c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(13) : see declaration of 'universities' c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(98) : error C2059: syntax error : '[' c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(100) : error C2228: left of '.university' must have class/struct/union         type is 'universities []' c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(100) : error C2228: left of '.places' must have class/struct/union c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(100) : fatal error C1903: unable to recover from previous error(s); stopping compilation Build log was saved at "file://c:\Dokumente und Einstellungen\Paul\Eigene Dateien\Visual Studio 2005\Projects\matching\matching\Debug\BuildLog.htm" matching - 27 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== Mar 22 '07 #42

 100+ P: 1,806 It may help you to investigate how structs work, which you can do here I think you want to do something like the "record" example at that url, and then you can declare (as an example) Expand|Select|Wrap|Line Numbers record myRecords[size];   Hope that's of some help Mar 22 '07 #45

 P: 99 I took the input file out simply because i wanted to tackle these code first. After that i will try to handle it. good idea. should i max_average_grade as an array? AAAACK!!! that should not be your first impulse! arrays are horribly tricky things and you should use them only when you need to. to figure out what to do with it, first, please tell me again what exactly its purpose is? Mar 22 '07 #47

 P: 40 i want to arrange the universities in this order: The university with the highest average grade. So my average_grade is to help me change with changing of position, so that after the for loop, the universities would be arraged in order of high their averge grade. Mar 22 '07 #48