473,421 Members | 1,536 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,421 software developers and data experts.

Matching students to university problem

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
  1. #include "stdafx.h"
  2. #include<iostream>
  3. using namespace std;
  4.  
  5. struct universities{
  6.       string name;
  7.       int places;
  8.       int average grade;
  9. } university[i];
  10.  
  11. struct student{
  12.     string name;
  13.     universities choice[i];
  14. }student[i]
  15.  
  16.  
  17. int _tmain(int argc, _TCHAR* argv[])
  18.  
  19. {
  20.     ifstream in;
  21.     string filename;
  22.     cout <<"give filname";
  23.     cin filename;
  24.  
  25.     in.open(filname, c_str());
  26.  
  27.     return 0;
  28. }
  29.  
Thanks alot in advance.
Mar 19 '07 #1
97 6106
Roonie
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
  1. int my_average_grade;
  2.  
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
luap
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
  1. #include "stdafx.h"
  2. #include<iostream>
  3. using namespace std;
  4.  
  5. struct universities{
  6.       string name;
  7.       int places;
  8.       int average grade;
  9. } university[i];
  10.  
  11. struct student{
  12.     string name;
  13.     universities choice[i];
  14.     int my_average_grade
  15. }student[i];
  16.  
  17.  
  18.  
  19.  
  20. for(int i=0;i<max_Uni;i++)
  21. {
  22.     universities.university[]=university;
  23. }
  24. for(int i=0;i<max_student;i++)
  25. {
  26.  
  27.  
  28.  
  29. double max average_grade=0;
  30. for(int i=0;i<max_uni;i++)
  31. {
  32.   for(int j=i+1;j<max_uni;j++)
  33.   {
  34.     if (university[i].average_grade < university[j].average_grade)
  35.     {
  36.     max average_grade=university[j].average_grade;
  37.     university[j].average_grade=university[i].average_grade[j];
  38.     university[i].average_grade=max average_grade;
  39.    }
  40.   }
  41.  
  42.  
  43.   for(int i=0;i<university.max_uni;i++)
  44.      {
  45.       cin >> university[i].max average_grade;
  46.       universities.university[i]=university.[i].max average_grade;
  47.       university[i].places=0;
  48.       while(university[i].places>0)
  49.       {
  50.        for(int i=0;i<Max.student;i++)
  51.        {
  52.            if(student[i].my_average_grade==university[i].average_grade &&    student[i].choice==university.name)
  53.            {
  54.                university[i].akzept=student.choice[i];
  55.  
  56.            }
  57.        }
  58.        i--;
  59.       }
  60.  
  61.   }
  62.  
Any suggestion on how best to represent the problem will be of great help.

Thanks alot once again in advance.
Mar 19 '07 #3
RedSon
5,000 Expert 4TB
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
  1. universities.university[]=university;
  2.  
Whatever it is, it isn't doing what you think it should be doing.
Mar 19 '07 #4
luap
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
  1. struct universities{
  2. string name;
  3. int places;
  4. int average grade;
  5. } university[i];
  6.  
  7. struct student{
  8. string name;
  9. universities choice[i];
  10. int my_average_grade
  11. }student[i];
  12.  
  13. double max average_grade=0;
  14.  
  15.  
  16.  
  17. for(int i=0;i<max_Uni;i++)
  18. {
  19. university[i].name=university;
  20. }
  21.  
  22. for(int i=0;i<max_student;i++)
  23. {
  24.  
  25.  
  26. for(int i=0;i<max_uni;i++)
  27. {
  28. for(int j=i+1;j<max_uni;j++)
  29. {
  30. if (university[i].average_grade < university[j].average_grade)
  31. {
  32. max average_grade=university[j].average_grade;
  33. university[j].average_grade=university[i].average_grade[j];
  34. university[i].average_grade=max average_grade;
  35. }
  36. }
  37.  
  38.  
  39. for(int i=0;i<university.max_uni;i++)
  40. {
  41. cin >> university[i].max average_grade;
  42. universities.university[i]=university.[i].max average_grade;
  43. university[i].places=0;
  44. while(university[i].places>0)
  45. {
  46. for(int i=0;i<Max.student;i++)
  47. {
  48. if(student[i].my_average_grade==university[i].average_grade && student[i].choice==university.name)
  49. {
  50. university[i].akzept=student.choice[i];
  51.  
  52. }
  53. }
  54. i--;
  55. }
Edit / Delete Reply
Reply
Mar 19 '07 #5
Niheel
2,460 Expert Mod 2GB
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
luap
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
Ganon11
3,652 Expert 2GB
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
sicarie
4,677 Expert Mod 4TB
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
Ganon11
3,652 Expert 2GB
Note: Three threads have been merged into this thread - there may be some discontinuity or confusion among posts.
Mar 20 '07 #10
luap
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
luap
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
  1.  for(int i=0;i<max_uni;i++)
  2. {
  3.   for(int j=i+1;j<max_uni;j++)
  4.   {
  5.     if (university[i].average_grade < university[j].average_grade)
  6.     {
  7.     max average_grade=university[j].average_grade;
  8.     university[j].average_grade=university[i].average_grade[j];
  9.     university[i].average_grade=max average_grade;
  10.    }
  11.   }
Mar 20 '07 #12
luap
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
  1. for(int i=0;i<max_uni;i++)
  2. {
  3.    for(int j=i+1;j<max_uni;j++)
  4.    {
  5.       if (university[i].average_grade < university[j].average_grade)
  6.       {
  7.          max average_grade=university[j].average_grade;
  8.          university[j].average_grade=university[i].average_grade[j];
  9.          university[i].average_grade=max average_grade;
  10.       }
  11.    }
  12. }
Mar 20 '07 #13
sicarie
4,677 Expert Mod 4TB
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
  1.  for(int i=0;i<max_uni;i++)
  2. {
  3.   for(int j=i+1;j<max_uni;j++)
  4.   {
  5.     if (university[i].average_grade < university[j].average_grade)
  6.     {
  7.     max average_grade=university[j].average_grade;
  8.     university[j].average_grade=university[i].average_grade[j];
  9.     university[i].average_grade=max average_grade;
  10.    }
  11.   }
That looks like valid code (though you might need to use '->' instead of the '.'s, but I'm not sure), have you tried plugging that into a compiler?
Mar 20 '07 #14
luap
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
  1. for(int i=0;i<university.max_uni;i++)
  2.      {
  3.       cin >> university[i].max average_grade;
  4.       universities.university[i]=university.[i].max average_grade;
  5.       university[i].places=0;
  6.       while(university[i].places>0)
  7.       {
  8.        for(int i=0;i<Max.student;i++)
  9.        {
  10.            if(student[i].my_average_grade==university[i].average_grade && student[i].choice==university.name)
  11.            {
  12.                university[i].akzept=student.choice[i];
  13.  
  14.            }
  15.        }
  16.        i--;
  17.       }
Mar 20 '07 #15
Roonie
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
dmjpro
2,476 2GB
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
sicarie
4,677 Expert Mod 4TB
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
Ganon11
3,652 Expert 2GB
Too late - I merged them again.
Mar 20 '07 #19
luap
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
  1. struct universities{
  2.       string name;
  3.       int places;
  4.       double average_grade;
  5.       int akzept;
  6. } university[i];
  7.  
  8. struct student{
  9.     string name;
  10.     universities choice[i];
  11.     double my_average_grade;
  12. }student[i];
  13.  
  14.  
  15. int _tmain(int argc, _TCHAR* argv[])
  16.  
  17. {
  18.     ifstream in;
  19.     string filename;
  20.     cout <<"give filname";
  21.  
  22.     in.open(filename, c_str());
  23.     {
  24.      while (!in.eof())
  25.      {
  26.        getline(in,filename);
  27.        cout << filename <<end;
  28.      }
This what my compiler tells me:

error C2228: left of '.open' must have class/struct/union
type is 'int'
: error C3861: 'c_str': identifier not found

: error C2228: left of '.eof' must have class/struct/union
type is 'int'

Please i need your help. Thanks in advance.
Mar 20 '07 #20
Roonie
99
where are you getting the name of the file to open?
Mar 20 '07 #21
luap
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
Roonie
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
Roonie
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
luap
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
  1. struct universities
  2.       {
  3.       string name;
  4.       int places[i];
  5.       double average_grade;
  6.       int akzept[i];
  7.       } university[i];
  8.  
  9. struct student
  10.    {
  11.     int id;
  12.     universities choice[i];
  13.     universities average_grade;
  14.     double my_average_grade;
  15.    }student[i];
  16.  
  17. struct matching_student{
  18.      universities[i] match;
  19.     student[i]matchd;
  20.     }matching[i];
Mar 21 '07 #25
Roonie
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
luap
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
  1.   for(int i=0;i<max_uni;i++)
  2.      {
  3.       cin >> university[j].max_average_grade;
  4.       university[i].average_grade=university.[j].max average_grade;
  5.  
  6.       while(university[i].places > 0 && university[i].average_grade)
  7.       {
  8.        for(int j=0;j<max.student;j++)
  9.         {
  10.            for(int k=0;k<student[j].choice[k];k++)
  11.            {
  12.              if(student[j].my_average_grade==university[i].average_grade &&        student[i].choice[k]==university[i].name)
  13.                {
  14.                university[i].akzept=student[j].choice[i];
  15.                }
  16.           }
  17.        }
  18.       }
  19.        --univesity[i].places;
  20.   }
Mar 21 '07 #27
Roonie
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
luap
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
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <string>
  4. #include <fstream>
  5. using namespace std;
  6.  
  7.  
  8.  
  9. struct universities
  10.       {
  11.       string name;
  12.       int places[i];
  13.       double average_grade;
  14.       int akzept[i];
  15.       } university[i];
  16.  
  17. struct student
  18.    {
  19.     int id;
  20.     universities choice[i];
  21.     universities average_grade;
  22.     double my_average_grade;
  23.    }student[i];
  24.  
  25. struct matching_student{
  26.      universities[i] match;
  27.     student[i]matchd;
  28.     }matching[i];
  29.  
  30.  
  31. int _tmain(int argc, _TCHAR* argv[])
  32.  
  33. {
  34.     ifstream in;
  35.     string filename;
  36.     cout <<"give filname";
  37.  
  38.     in.open(filename, c_str());
  39.     {
  40.      while (!in.eof())
  41.      {
  42.        getline(in,filename);
  43.        cout << filename <<endl;
  44.      }
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  double max_average_grade
  52.  int max_student, student_no;
  53.  int max_uni;
  54.  
  55.  
  56. universities university[i];
  57. for(int i=0;i<max_uni;i++)
  58. {
  59.     university[i].name=university;
  60. }
  61.  
  62. student student[i];
  63.  
  64. for(int i=0;i<max_student;i++)
  65. {
  66.     student[i].id=student_no;
  67. }
  68.  
  69.  
  70.  for(int i=0;i<max_uni;i++)
  71.   {
  72.     for(int j=i+1;j<max_uni;j++)
  73.     {
  74.      if (university[i].average_grade < university[j].average_grade)
  75.       {
  76.       max_average_grade=university[j].average_grade;
  77.       university[j].average_grade=university[i].average_grade[i];
  78.       university[i].average_grade=max_average_grade;
  79.       }
  80.     } 
  81.   }
  82.  
  83.  
  84.  for(int i=0; i<max_uni;i++)
  85.  {
  86.  
  87.  
  88.  
  89.   for(int i=0;i<max_uni;i++)
  90.      {
  91.       cin >> university[j].max_average_grade;
  92.       university[i].average_grade=university.[j].max average_grade;
  93.  
  94.       while(university[i].places > 0 && university[i].average_grade)
  95.       {
  96.        for(int j=0;j<max.student;j++)
  97.         {
  98.            for(int k=0;k<student[j].choice[k];k++)
  99.            {
  100.              if(student[j].my_average_grade==university[i].average_grade && student[i].choice[k]==university[i].name)
  101.                {
  102.                university[i].akzept=student[j].choice[i];
  103.                }
  104.           }
  105.        }
  106.       }
  107.        --univesity[i].places;
  108.   }  
  109.   }
  110.   cin.filename();
  111.   return 0;
  112.   }
Mar 21 '07 #29
Roonie
99
. . . and the problem youre having is???

(well get you to a full post sooner or later ;))
Mar 21 '07 #30
Roonie
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
luap
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
luap
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
Roonie
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
  1. while (!in.eof())
  2. {
  3.     getline(in,filename);
  4.     cout << filename <<endl;
  5. }
is inputting your entire source file without you doing anything with the data . . . all you will have after this loop is executed is the last line of the file stored in "in" and the filename on the screen a few dozen (or thousand) times . . . if getline works like you think its does. (which you should double check.)

3) there are several basic syntax errors in your code.

and 4) you still havent done anything about properly handling the name of your input file. (see post #23.)
Mar 21 '07 #34
DeMan
1,806 1GB
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
  1. struct student
  2. {
  3.   int id;
  4.   universities choice[]; /* Does this need to be an array and is it fixed size? */
  5.   universities average_grade;
  6.   double my_average_grade;
  7. }student;
  8.  
  9. student theseStudents[];
  10.  
Mar 21 '07 #35
luap
40
please i would like to know which form of the declaration is correct.
1.
Expand|Select|Wrap|Line Numbers
  1. int number[i];
  2.      int number[j];
  3. ist this initialisation neccessary
  4. for(int i=0;i<number[i];i++)
  5. {
  6.     university[number[i]].name=university;
  7. }
2.

Expand|Select|Wrap|Line Numbers
  1. for(int i=0;i<max_uni;i++)
  2.   {
  3.     for(int j=i+1;j<max_uni;j++)
  4.     {
  5.      if (university[number[i]].average_grade < university[j].average_grade)
  6.       {
  7.       max_average_grade=university[j].average_grade;
  8.       university[j].average_grade=university[i].average_grade[i];
  9.       university[i].average_grade=max_average_grade;
  10.       }
  11.     } 
  12.   }
3.
I will like to know whether the code should rather be this.

Expand|Select|Wrap|Line Numbers
  1. for(int number[i]; number[max_uni];++number[i]) 
  2.    {
  3.     for(int number[J=i+1]; number[max_uni];++number[j++])
  4.      if(partner_university[number[i]].<partner_university[number[j]
  5.        {
  6.        max_average_grade=patner_university[number[j]]:
  7.        partner_university[number[j]]=partner_university[number[i]];
  8.        partner_university[number[i]]=max_average_grade;
  9.        }
thanks in advance.
Mar 21 '07 #36
sicarie
4,677 Expert Mod 4TB
Have you tried putting them in a compiler and running them yourself?
Mar 21 '07 #37
Roonie
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
luap
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
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <string>
  4. using namespace std;
  5.  
  6.  
  7.  
  8.  
  9. struct universities
  10.       {
  11.       string name;
  12.       int places;
  13.       double average_grade;
  14.       }university;
  15.  
  16.  
  17. struct student
  18.  {
  19.   int id;
  20.   universities choice[6]; 
  21.   universities average_grade;
  22.   double my_average_grade;
  23. }student;
  24.  
  25.  
  26.  
  27.  
  28. struct matching_student{
  29.      universities[i] match;
  30.      student[i]matchd;
  31.      }matching; 
  32.    matching;
  33.  
  34.  
  35. int _tmain(int argc, _TCHAR* argv[])
  36.  
  37. { double max_average_grade
  38.   int number[i];
  39.   int number[j];
  40.   int number[k];
  41.   int max_student, student_no;
  42.   int max_uni;
  43.  
  44.   universities university[number[i]];
  45.   student student[number[j]] ;
  46.  
  47.     for(int number[j]=0;number[i]<number[max_uni];++number[i])
  48. {
  49.     university[number[i]].name=university;
  50. }
  51.  
  52.  
  53.  
  54. for(int number[j]=0;number[j]<number[max_student];++number[j])
  55. {
  56.     student[number[i]].id=student_no;
  57. }
  58.  
  59.  
  60.  for(int number[i]=0;number[i]<number[max_uni];++number[i])
  61.   {
  62.     for(int number[j=i+1];number[j]<number[max_uni];++number[i])
  63.     {
  64.      if (university[number[i]].average_grade < university[number[i]].average_grade)
  65.       {
  66.           max_average_grade=university[number[j]].average_grade;
  67.           university[number[]].average_grade=university[number[i]].average_grade;
  68.           university[number[i]].average_grade=max_average_grade;
  69.       }
  70.     } 
  71.   }
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  for(int number[i]; number[i]<=number[max_uni];++number[i])
  88.  {
  89.  
  90.  
  91.   for(int number[i]=0;number[i]<=number[max_uni];++number[i])
  92.      {
  93.       cout << university[j].max_average_grade;
  94.       university[i].average_grade=university.[j].max average_grade;
  95.  
  96.       while(university[number[i]].places > 0 && university[number[i]].average_grade)
  97.       {
  98.        for(int number[j]=0;number[i]<number[max.student];++number[j])
  99.         {
  100.            for(int number[k]=0;number[k]<=[student[j].choice[6];++number[k])
  101.            {
  102.              if(student[number[j]].my_average_grade==university[number[j]].average_grade && student[number[j]].choice[number[k]]==university[number[i]].name)
  103.                {
  104.                university[number[i]].akzept=student[number[j]].choice[k];
  105.                }
  106.           }
  107.        }
  108.      }
  109.        --university[number[j]].places;
  110.   } }  
  111.  
  112.  
  113.   return 0;
  114.   }
Expand|Select|Wrap|Line Numbers
  1. :\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(31) : error C2337: 'i' : attribute not found
  2. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(31) : error C2061: syntax error : identifier 'match'
  3. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(31) : error C2238: unexpected token(s) preceding ';'
  4. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(32) : error C2065: 'i' : undeclared identifier
  5. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(32) : error C2146: syntax error : missing ';' before identifier 'matchd'
  6. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(32) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
  7. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(32) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
  8. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(34) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
  9. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(34) : error C2371: 'matching' : redefinition; different basic types
  10.         c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(33) : see declaration of 'matching'
  11. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(40) : error C2144: syntax error : 'int' should be preceded by ';'
  12. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(41) : error C2065: 'j' : undeclared identifier
  13. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(41) : error C2086: 'int number[1]' : redefinition
  14.         c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(40) : see declaration of 'number'
  15. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(42) : error C2065: 'k' : undeclared identifier
  16. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(42) : error C2086: 'int number[1]' : redefinition
  17.         c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(40) : see declaration of 'number'
  18. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(46) : error C2133: 'university' : unknown size
  19. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(47) : error C2146: syntax error : missing ';' before identifier 'student'
  20. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(49) : error C2440: 'initializing' : cannot convert from 'int' to 'int [1]'
  21.         There are no conversions to array types, although there are conversions to references or pointers to arrays
  22. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(51) : error C2228: left of '.name' must have class/struct/union
  23. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(56) : error C2440: 'initializing' : cannot convert from 'int' to 'int [1]'
  24.         There are no conversions to array types, although there are conversions to references or pointers to arrays
  25. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(58) : error C2228: left of '.id' must have class/struct/union
  26. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(62) : error C2440: 'initializing' : cannot convert from 'int' to 'int [1]'
  27.         There are no conversions to array types, although there are conversions to references or pointers to arrays
  28. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(64) : error C2133: 'number' : unknown size
  29. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(66) : error C2228: left of '.average_grade' must have class/struct/union
  30. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(66) : error C2228: left of '.average_grade' must have class/struct/union
  31. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(68) : error C2228: left of '.average_grade' must have class/struct/union
  32. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(69) : error C2059: syntax error : ']'
  33. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(70) : error C2228: left of '.average_grade' must have class/struct/union
  34. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(93) : error C2440: 'initializing' : cannot convert from 'int' to 'int [1]'
  35.         There are no conversions to array types, although there are conversions to references or pointers to arrays
  36. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(95) : error C2228: left of '.max_average_grade' must have class/struct/union
  37. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(96) : error C2228: left of '.average_grade' must have class/struct/union
  38. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(96) : error C2059: syntax error : '['
  39. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(98) : error C2228: left of '.university' must have class/struct/union
  40.         type is 'universities []'
  41. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(98) : error C2228: left of '.places' must have class/struct/union
  42. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(98) : error C2228: left of '.average_grade' must have class/struct/union
  43. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(98) : fatal error C1903: unable to recover from previous error(s); stopping compilation
  44. Build log was saved at "file://c:\Dokumente und Einstellungen\Paul\Eigene Dateien\Visual Studio 2005\Projects\matching\matching\Debug\BuildLog.htm"
  45. matching - 35 error(s), 0 warning(s)
  46. ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Please i where could my problem be?
Thanks.
Mar 21 '07 #39
Roonie
99
Expand|Select|Wrap|Line Numbers
  1. int number[i];
  2. int number[j];
  3. int number[k];
. . . do you mean?
Expand|Select|Wrap|Line Numbers
  1. 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
Roonie
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
  1. int length = 100;
  2. 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
luap
40
please after i tried to change my code,
hier is changed version.

/
Expand|Select|Wrap|Line Numbers
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <string>
  4. using namespace std;
  5. typedef max_uni 15;
  6. typedef max_student 40;
  7.  
  8.  
  9.  
  10. struct universities
  11.       {
  12.       string name;
  13.       int places;
  14.       double average_grade;
  15.       }university;
  16.  
  17.  
  18. struct student
  19.  {
  20.   int id;
  21.   universities choice[6]; 
  22.   universities average_grade;
  23.   double my_average_grade;
  24. }student;
  25.  
  26.  
  27.  
  28.  
  29. struct matching_student{
  30.      universities[i] match;
  31.      student[i]matchd;
  32.      }matching; 
  33.    matching;
  34.  
  35.  
  36. int _tmain(int argc, _TCHAR* argv[])
  37.  
  38. {
  39.   double max_average_grade;
  40.   int i, j, k; 
  41.  
  42.  
  43.   int max_student, student_no;
  44.   int max_uni;
  45.  
  46.   universities university[max_uni];
  47.   student student[max_student] ;
  48.  
  49.     for(int i=0;i<=max_uni;i++)
  50.     {
  51.        university[i].name=university;
  52.     }
  53.  
  54.  
  55.  
  56. for(int j=0;j<max_student;j++)
  57. {
  58.     student[j].id=student_no;
  59. }
  60.  
  61.  
  62.  for(int i=0;i<max_uni;i++)
  63.   {
  64.     for(int j=i+1;j<max_uni;i++)
  65.     {
  66.      if (university[i].average_grade < university[j].average_grade)
  67.       {
  68.           max_average_grade=university[j].average_grade;
  69.           university[j].average_grade=university[i].average_grade;
  70.           university[i].average_grade=max_average_grade;
  71.       }
  72.     } 
  73.   }
  74.  
  75.  
  76. for(int i;i<=max._uni;i++)
  77.  {
  78.  
  79.  
  80.      for(int j=0;j<=max_uni;j++)
  81.      {
  82.       cout << university[j].max_average_grade;
  83.       university[i].average_grade=university.[j].max average_grade;
  84.  
  85.       while(university[i].places > 0 && university[i].average_grade)
  86.       {
  87.        for(int j=0;j<max.student;j++)
  88.         {
  89.            for(int k=0;k<=student[j].choice[6];k++)
  90.            {
  91.              if(student[j].my_average_grade==university[j].average_grade && student[j].choice[k]==university[i].name)
  92.                {
  93.                university[i].akzept=student[j].choice[k];
  94.                }
  95.           }
  96.        }
  97.      }
  98.        --university[j].places;
  99.   }  
  100.  
  101.  
  102.   return 0;
  103.  
  104.   }
Expand|Select|Wrap|Line Numbers
  1. --- Build started: Project: matching, Configuration: Debug Win32 ------
  2. Compiling...
  3. matching.cpp
  4. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(7) : error C2143: syntax error : missing ';' before 'constant'
  5. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(7) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
  6. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(8) : error C2143: syntax error : missing ';' before 'constant'
  7. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(8) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
  8. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(32) : error C2337: 'i' : attribute not found
  9. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(32) : error C2061: syntax error : identifier 'match'
  10. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(32) : error C2238: unexpected token(s) preceding ';'
  11. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(33) : error C2065: 'i' : undeclared identifier
  12. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(33) : error C2146: syntax error : missing ';' before identifier 'matchd'
  13. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(33) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
  14. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(33) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
  15. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(35) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
  16. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(35) : error C2371: 'matching' : redefinition; different basic types
  17.         c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(34) : see declaration of 'matching'
  18. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(48) : error C2057: expected constant expression
  19. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(48) : error C2466: cannot allocate an array of constant size 0
  20. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(48) : error C2133: 'university' : unknown size
  21. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(49) : error C2146: syntax error : missing ';' before identifier 'student'
  22. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(49) : error C2676: binary '[' : 'student' does not define this operator or a conversion to a type acceptable to the predefined operator
  23. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(53) : error C2679: binary '=' : no operator found which takes a right-hand operand of type 'universities []' (or there is no acceptable conversion)
  24.         c:\programme\microsoft visual studio 8\vc\include\xstring(875): could be 'std::basic_string<_Elem,_Traits,_Ax> &std::basic_string<_Elem,_Traits,_Ax>::operator =(const std::basic_string<_Elem,_Traits,_Ax> &)'
  25.         with
  26.         [
  27.             _Elem=char,
  28.             _Traits=std::char_traits<char>,
  29.             _Ax=std::allocator<char>
  30.         ]
  31.         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 *)'
  32.         with
  33.         [
  34.             _Elem=char,
  35.             _Traits=std::char_traits<char>,
  36.             _Ax=std::allocator<char>
  37.         ]
  38.         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)'
  39.         with
  40.         [
  41.             _Elem=char,
  42.             _Traits=std::char_traits<char>,
  43.             _Ax=std::allocator<char>
  44.         ]
  45.         while trying to match the argument list '(std::string, universities [])'
  46. 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
  47. 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
  48. 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
  49. 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'
  50.         c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(13) : see declaration of 'universities'
  51. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(98) : error C2059: syntax error : '['
  52. 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
  53.         type is 'universities []'
  54. 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
  55. 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
  56. Build log was saved at "file://c:\Dokumente und Einstellungen\Paul\Eigene Dateien\Visual Studio 2005\Projects\matching\matching\Debug\BuildLog.htm"
  57. matching - 27 error(s), 0 warning(s)
  58. ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Mar 22 '07 #42
luap
40
Hallo it me again. I am still working on my code. I am still encoutering difficulties.

Here ist my completed version.

Expand|Select|Wrap|Line Numbers
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <string>
  4. using namespace std;
  5.  
  6.  
  7.  
  8.  
  9.  
  10. struct universities
  11.       {
  12.       string name;
  13.       int places;
  14.       double average_grade;
  15.       }university;
  16.  
  17.  
  18. struct students
  19.  {
  20.   int id;
  21.   universities choice[6]; 
  22.   universities average_grade;
  23.   double my_average_grade;
  24. }student;
  25.  
  26.  
  27.  
  28. struct matching_student{
  29.      universities match;
  30.      students matchd;
  31.      }matching; 
  32.  
  33.  
  34.  
  35. int _tmain(int argc, _TCHAR* argv[])
  36.  
  37. {
  38.   double max_average_grade;
  39.   int i, j, k; 
  40.  
  41.  
  42.   int no_of_student, student_no;
  43.   int no_of_uni,uni_start;
  44.  
  45.   no_of_uni=30;
  46.   universities university[no_of_uni];
  47.   no_of_student=50;
  48.   students student[no_of_student]; 
  49.  
  50.  
  51.  
  52. for(int i=0;i<=30;i++)
  53. {
  54.  university[no_of_uni].name=uni_start;
  55.  }    
  56.  
  57. for(int j=0;j<50;j++)
  58. {
  59.     student[no_of_student].id=student_no;
  60. }
  61.  
  62.  
  63.  
  64.  
  65.  for(int i=0;i<30;i++)
  66.   {
  67.     for(int j=i+1;j<30;i++)
  68.     {
  69.      if (university[i].average_grade < university[j].average_grade)
  70.       {
  71.           max_average_grade=university[j].average_grade;
  72.           university[j].average_grade=university[i].average_grade;
  73.           university[i].average_grade=max_average_grade;
  74.       }
  75.     } 
  76.   }
  77.  
  78.  
  79. for(int i;i<=30;i++)
  80.  {
  81.  
  82.  
  83.      for(int j=0;j<=30;j++)
  84.      {
  85.       cout << university[j].max_average_grade;
  86.       university[i].average_grade=university.[j].max average_grade;
  87.  
  88.       while(university[i].places > 0 && university[i].average_grade)
  89.       {
  90.        for(int j=0;j<=50;j++)
  91.         {
  92.            for(int k=0;k<=student[j].choice[6];k++)
  93.            {
  94.              if(student[j].my_average_grade==university[j].average_grade && student[j].choice[k]==university[i].name)
  95.                {
  96.                university[i].akzept=student[j].choice[k];
  97.                }
  98.           }
  99.        }
  100.      }
  101.        --university[i].places;
  102.   }  
  103.  
  104.  
  105.   return 0;
  106.   }
This is what the complier tells me.
Expand|Select|Wrap|Line Numbers
  1. dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(48) : error C2057: expected constant expression
  2.  
  3. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(48) : error C2466: cannot allocate an array of constant size 0
  4.  
  5. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(48) : error C2133: 'university' : unknown size   (ps i want to know way, since i already decleared the number of the universities)
  6.  
  7. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(50) : error C2057: expected constant expression
  8.  
  9. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(50) : error C2466: cannot allocate an array of constant size 0
  10.  
  11. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(50) : error C2133: 'student' : unknown size
  12.  
  13. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(87) : error C2039: 'max_average_grade' : is not a member of 'universities'
  14. (ps i also what know why)
  15.  
  16.         c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(13) : see declaration of 'universities'
  17. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(88) : error C2059: syntax error : '['
  18. c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(90) : error C2228: left of '.university' must have class/struct/union
  19.  
Thanks in advance
Mar 22 '07 #43
Roonie
99
Expand|Select|Wrap|Line Numbers
  1.     double max_average_grade;
  2.     int i, j, k; 
  3.  
  4.  
  5.     int no_of_student, student_no;
  6.     int no_of_uni,uni_start;
  7.  
  8.     no_of_uni=30;
  9.     universities university[no_of_uni];
  10.     no_of_student=50;
  11.     students student[no_of_student]; 
good!

i think a few of the errors you are finding though are because i lied. (or didnt fully qualify - sorry) when your compiler says that it "expected a constant expression" it means that no_of_uni and no_of_student are variable. you should either declare them "const" or hardcode the values into the array declarations like this:
Expand|Select|Wrap|Line Numbers
  1.     const int no_of_uni=30;
  2.     universities university[no_of_uni];
  3.     const int no_of_student=50;
  4.     students student[no_of_student]; 
  5.  
  6. //or:
  7.  
  8.     universities university[30];
  9.     students student[50];
(i usually do the first, just for the sake of readability, but its really a personal choice.) also, this line
Expand|Select|Wrap|Line Numbers
  1. university[i].average_grade=university.[j].max average_grade;
needs to look more like this:
Expand|Select|Wrap|Line Numbers
  1. university[i].average_grade=university[j].max_average_grade;
and we need to figure out where max_average_grade went to in the first place, as well as akzept. (they both seem to have been dropped from your struct declarations but youre still trying to use them in your code.) it also looks like here
Expand|Select|Wrap|Line Numbers
  1. for(int i=0;i<=30;i++)
  2. {
  3.     university[no_of_uni].name=uni_start;
  4. for(int j=0;j<50;j++)
  5. {
  6.     student[no_of_student].id=student_no;
  7. }
that uni_start and student_no do not yet have values. what happened to your input file?
Mar 22 '07 #44
DeMan
1,806 1GB
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
  1. record myRecords[size];
  2.  
Hope that's of some help
Mar 22 '07 #45
luap
40
I took the input file out simply because i wanted to tackle these code first. After that i will try to handle it.



please i would like to know how to make max_average_grade compactible with
universities average_grade, should i max_average_grade as an array?

Expand|Select|Wrap|Line Numbers
  1.  :\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(88) : error C2039: 'max_average_grade' : is not a member of 'universities'
This is how my code looks as at the moment.

Expand|Select|Wrap|Line Numbers
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <string>
  4. using namespace std;
  5.  
  6.  
  7.  
  8.  
  9.  
  10. struct universities
  11.       {
  12.       string name;
  13.       int places;
  14.       double average_grade;
  15.       int akzept;
  16.       }university;
  17.  
  18.  
  19. struct students
  20.  {
  21.   int id;
  22.   universities choice[6]; 
  23.   universities average_grade;
  24.   double my_average_grade;
  25. }student;
  26.  
  27.  
  28.  
  29. struct matching_student{
  30.        universities match;
  31.        students matchd;
  32.        }matching; 
  33.  
  34.  
  35.  
  36. int _tmain(int argc, _TCHAR* argv[])
  37.  
  38. {
  39.   double max_average_grade;
  40.   int i, j, k; 
  41.  
  42.  
  43.   int student_no;
  44.   int uni_start;
  45.  
  46.   const int no_of_uni=30;
  47.   universities university[no_of_uni];
  48.   const int no_of_student=50;
  49.   students student[no_of_student]; 
  50.  
  51.  
  52.  
  53.  
  54. for(int i=0;i<=30;i++)
  55. {
  56.  university[no_of_uni].name=uni_start;
  57.  }    
  58.  
  59. for(int j=0;j<50;j++)
  60. {
  61.     student[no_of_student].id=student_no;
  62. }
  63.  
  64.  
  65.  
  66.  
  67.  for(int i=0;i<30;i++)
  68.   {
  69.     for(int j=i+1;j<30;i++)
  70.     {
  71.      if (university[i].average_grade < university[j].average_grade)
  72.       {
  73.           max_average_grade=university[j].average_grade;
  74.           university[j].average_grade=university[i].average_grade;
  75.           university[i].average_grade=max_average_grade;
  76.       }
  77.     } 
  78.   }
  79.  
  80.  
  81. for(int i;i<=30;i++)
  82.  {
  83.  
  84.  
  85.      for(int j=0;j<=30;j++)
  86.      {
  87.       cout << university[j].max_average_grade;
  88.       university[i].average_grade=university.[j].max_average_grade;
  89.  
  90.       while(university[i].places > 0 && university[i].average_grade)
  91.       {
  92.        for(int j=0;j<=50;j++)
  93.         {
  94.            for(int k=0;k<=student[j].choice[6];k++)
  95.            {
  96.              if(student[j].my_average_grade==university[j].average_grade && student[j].choice[k]==university[i].name)
  97.                {
  98.                university[i].akzept=student[j].choice[k];
  99.                }
  100.           }
  101.        }
  102.      }
  103.        --university[i].places;
  104.   }  
  105.  
  106.  
  107.   return 0;
  108.   }
Thanks.
Mar 22 '07 #46
Roonie
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
luap
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
Roonie
99
Expand|Select|Wrap|Line Numbers
  1. for(int i=0;i<30;i++)
  2. {
  3. for(int j=i+1;j<30;i++)
  4. {
  5. if (university[i].average_grade < university[j].average_grade)
  6. {
  7. max_average_grade=university[j].average_grade;
  8. university[j].average_grade=university[i].average_grade;
  9. university[i].average_grade=max_average_grade;
  10. }
  11. }
it looks like thats what youre doing here . . . is it possible you dont need max_average_grade anywhere else? therefore it doesnt need to be in your structs or anywhere else in your code.

what about akzept?
Mar 22 '07 #49
luap
40
for my akzept i just want to allocate / match a student to a university when there is still a place aviable. This must hold that :

1.The student has choosen the university and also have the the required grade.
2. There must be a place free at the university.

Thanks.
Mar 22 '07 #50

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Sridhar R | last post by:
We are the students of Anna University and would like to share our thoughts on Python. Here it is http://cs.annauniv.edu/~portal/wiki/index.php/Python
5
by: david hepworth | last post by:
Hi All I will try to explain my problem. I am wishing to apply a template to the following XML. There are multiple event nodes within the register root node. For each of the event nodes there...
24
by: Mary Rosemount | last post by:
http://www.studentsforacademicfreedom.org/index.html
17
by: JunDa.Huang | last post by:
I am a university student, How to study program language well ?
18
by: Drayno241 | last post by:
I'm working in access 2002. I have three tables : 1- District Data (Student ID, name, grade, etc) 2- Rosters (RRec ID,Campus, Teacher ID) 3- Students on Roster(SRec ID, RRec ID, Student ID) ...
7
by: blaine | last post by:
Hey everyone, For the regular expression gurus... I'm trying to write a string matching algorithm for genomic sequences. I'm pulling out Genes from a large genomic pattern, with certain start...
4
by: pavanponnapalli | last post by:
hi, Here is my Code as under: #! /usr/bin/perl -w use DBI; my %hash; my @arr; my @arr1; my @arr2;
1
by: roxys | last post by:
Hello, I was wondering if someone could help me a bit here. Im trying to desing an electronic university students enrollement system. The system requirements are as follows: 1.Students can...
8
by: mfaisalwarraich | last post by:
hello, im trying to make an attendance record. im using a form where im entering two values, 1. Date 2. Absent Students im entering roll numbers of the absent students separated by "-"...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.