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. -
#include "stdafx.h"
-
#include<iostream>
-
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.
97 6106
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
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.
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. -
#include "stdafx.h"
-
#include<iostream>
-
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<max_Uni;i++)
-
{
-
universities.university[]=university;
-
}
-
for(int i=0;i<max_student;i++)
-
{
-
-
-
-
double max average_grade=0;
-
for(int i=0;i<max_uni;i++)
-
{
-
for(int j=i+1;j<max_uni;j++)
-
{
-
if (university[i].average_grade < university[j].average_grade)
-
{
-
max average_grade=university[j].average_grade;
-
university[j].average_grade=university[i].average_grade[j];
-
university[i].average_grade=max average_grade;
-
}
-
}
-
-
-
for(int i=0;i<university.max_uni;i++)
-
{
-
cin >> 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<Max.student;i++)
-
{
-
if(student[i].my_average_grade==university[i].average_grade && student[i].choice==university.name)
-
{
-
university[i].akzept=student.choice[i];
-
-
}
-
}
-
i--;
-
}
-
-
}
-
Any suggestion on how best to represent the problem will be of great help.
Thanks alot once again in advance.
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: -
universities.university[]=university;
-
Whatever it is, it isn't doing what you think it should be doing.
please i tried to make some changes in the programmme. Would someone please look
through for me again?
Thanks alot. -
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<max_Uni;i++)
-
{
-
university[i].name=university;
-
}
-
-
for(int i=0;i<max_student;i++)
-
{
-
-
-
for(int i=0;i<max_uni;i++)
-
{
-
for(int j=i+1;j<max_uni;j++)
-
{
-
if (university[i].average_grade < university[j].average_grade)
-
{
-
max average_grade=university[j].average_grade;
-
university[j].average_grade=university[i].average_grade[j];
-
university[i].average_grade=max average_grade;
-
}
-
}
-
-
-
for(int i=0;i<university.max_uni;i++)
-
{
-
cin >> 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<Max.student;i++)
-
{
-
if(student[i].my_average_grade==university[i].average_grade && student[i].choice==university.name)
-
{
-
university[i].akzept=student.choice[i];
-
-
}
-
}
-
i--;
-
}
Edit / Delete Reply
Reply
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.
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.
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.
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?
Note: Three threads have been merged into this thread - there may be some discontinuity or confusion among posts.
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 .
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. -
for(int i=0;i<max_uni;i++)
-
{
-
for(int j=i+1;j<max_uni;j++)
-
{
-
if (university[i].average_grade < university[j].average_grade)
-
{
-
max average_grade=university[j].average_grade;
-
university[j].average_grade=university[i].average_grade[j];
-
university[i].average_grade=max average_grade;
-
}
-
}
I want to arrange the universities with the highst average grade requirement first
Am i on the right track.
Thanks. - for(int i=0;i<max_uni;i++)
-
{
-
for(int j=i+1;j<max_uni;j++)
-
{
-
if (university[i].average_grade < university[j].average_grade)
-
{
-
max average_grade=university[j].average_grade;
-
university[j].average_grade=university[i].average_grade[j];
-
university[i].average_grade=max average_grade;
-
}
-
}
-
}
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. -
for(int i=0;i<max_uni;i++)
-
{
-
for(int j=i+1;j<max_uni;j++)
-
{
-
if (university[i].average_grade < university[j].average_grade)
-
{
-
max average_grade=university[j].average_grade;
-
university[j].average_grade=university[i].average_grade[j];
-
university[i].average_grade=max average_grade;
-
}
-
}
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?
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 - for(int i=0;i<university.max_uni;i++)
-
{
-
cin >> 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<Max.student;i++)
-
{
-
if(student[i].my_average_grade==university[i].average_grade && student[i].choice==university.name)
-
{
-
university[i].akzept=student.choice[i];
-
-
}
-
}
-
i--;
-
}
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.
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
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...).
Too late - I merged them again.
Hello nice friends, i am here once again seeking your help.
I want to know, how to solve this problem. - 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 <<end;
-
}
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.
where are you getting the name of the file to open?
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!
well, i only ask because it doesnt look like your actually passing the name of the file into the variable filename.
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.
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. - 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];
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 . . .
Thanks, just another quesition.
could please tell if this code is correct, if not how schould write it then.
Thanks again. - for(int i=0;i<max_uni;i++)
-
{
-
cin >> 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<max.student;j++)
-
{
-
for(int k=0;k<student[j].choice[k];k++)
-
{
-
if(student[j].my_average_grade==university[i].average_grade && student[i].choice[k]==university[i].name)
-
{
-
university[i].akzept=student[j].choice[i];
-
}
-
}
-
}
-
}
-
--univesity[i].places;
-
}
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.)
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.
. . . and the problem youre having is???
(well get you to a full post sooner or later ;))
(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.)
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 .
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
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 - while (!in.eof())
-
{
-
getline(in,filename);
-
cout << filename <<endl;
-
}
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.)
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: -
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[];
-
please i would like to know which form of the declaration is correct.
1. - int number[i];
-
int number[j];
-
ist this initialisation neccessary
-
for(int i=0;i<number[i];i++)
-
{
-
university[number[i]].name=university;
-
}
2. - for(int i=0;i<max_uni;i++)
-
{
-
for(int j=i+1;j<max_uni;j++)
-
{
-
if (university[number[i]].average_grade < university[j].average_grade)
-
{
-
max_average_grade=university[j].average_grade;
-
university[j].average_grade=university[i].average_grade[i];
-
university[i].average_grade=max_average_grade;
-
}
-
}
-
}
3.
I will like to know whether the code should rather be this. - for(int number[i]; number[max_uni];++number[i])
-
{
-
for(int number[J=i+1]; number[max_uni];++number[j++])
-
if(partner_university[number[i]].<partner_university[number[j]
-
{
-
max_average_grade=patner_university[number[j]]:
-
partner_university[number[j]]=partner_university[number[i]];
-
partner_university[number[i]]=max_average_grade;
-
}
thanks in advance.
Have you tried putting them in a compiler and running them yourself?
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.
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. - :\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(31) : error C2337: 'i' : attribute not found
-
c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(31) : error C2061: syntax error : identifier 'match'
-
c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(31) : error C2238: unexpected token(s) preceding ';'
-
c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(32) : error C2065: 'i' : undeclared identifier
-
c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(32) : error C2146: syntax error : missing ';' before identifier 'matchd'
-
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
-
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
-
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
-
c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(34) : error C2371: 'matching' : redefinition; different basic types
-
c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(33) : see declaration of 'matching'
-
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 ';'
-
c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(41) : error C2065: 'j' : undeclared identifier
-
c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(41) : error C2086: 'int number[1]' : redefinition
-
c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(40) : see declaration of 'number'
-
c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(42) : error C2065: 'k' : undeclared identifier
-
c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(42) : error C2086: 'int number[1]' : redefinition
-
c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(40) : see declaration of 'number'
-
c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(46) : error C2133: 'university' : unknown size
-
c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(47) : error C2146: syntax error : missing ';' before identifier 'student'
-
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]'
-
There are no conversions to array types, although there are conversions to references or pointers to arrays
-
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
-
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]'
-
There are no conversions to array types, although there are conversions to references or pointers to arrays
-
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
-
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]'
-
There are no conversions to array types, although there are conversions to references or pointers to arrays
-
c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(64) : error C2133: 'number' : unknown size
-
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
-
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
-
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
-
c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(69) : error C2059: syntax error : ']'
-
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
-
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]'
-
There are no conversions to array types, although there are conversions to references or pointers to arrays
-
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
-
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
-
c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(96) : error C2059: syntax error : '['
-
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
-
type is 'universities []'
-
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
-
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
-
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
-
Build log was saved at "file://c:\Dokumente und Einstellungen\Paul\Eigene Dateien\Visual Studio 2005\Projects\matching\matching\Debug\BuildLog.htm"
-
matching - 35 error(s), 0 warning(s)
-
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Please i where could my problem be?
Thanks.
- int number[i];
-
int number[j];
-
int number[k];
. . . do you mean?
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.
. . . 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: - 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.
please after i tried to change my code,
hier is changed version.
/ -
--- Build started: Project: matching, Configuration: Debug Win32 ------
-
Compiling...
-
matching.cpp
-
c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(7) : error C2143: syntax error : missing ';' before 'constant'
-
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
-
c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(8) : error C2143: syntax error : missing ';' before 'constant'
-
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
-
c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(32) : error C2337: 'i' : attribute not found
-
c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(32) : error C2061: syntax error : identifier 'match'
-
c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(32) : error C2238: unexpected token(s) preceding ';'
-
c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(33) : error C2065: 'i' : undeclared identifier
-
c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(33) : error C2146: syntax error : missing ';' before identifier 'matchd'
-
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
-
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
-
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
-
c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(35) : error C2371: 'matching' : redefinition; different basic types
-
c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(34) : see declaration of 'matching'
-
c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(48) : error C2057: expected constant expression
-
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
-
c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(48) : error C2133: 'university' : unknown size
-
c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(49) : error C2146: syntax error : missing ';' before identifier 'student'
-
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
-
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)
-
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> &)'
-
with
-
[
-
_Elem=char,
-
_Traits=std::char_traits<char>,
-
_Ax=std::allocator<char>
-
]
-
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<char>,
-
_Ax=std::allocator<char>
-
]
-
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<char>,
-
_Ax=std::allocator<char>
-
]
-
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 ==========
Hallo it me again. I am still working on my code. I am still encoutering difficulties.
Here ist my completed version.
This is what the complier tells me. -
dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(48) : error C2057: expected constant expression
-
-
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
-
-
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)
-
-
c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(50) : error C2057: expected constant expression
-
-
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
-
-
c:\dokumente und einstellungen\paul\eigene dateien\visual studio 2005\projects\matching\matching\matching.cpp(50) : error C2133: 'student' : unknown size
-
-
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'
-
(ps i also what know why)
-
-
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(88) : error C2059: syntax error : '['
-
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
-
Thanks in advance
- double max_average_grade;
-
int i, j, k;
-
-
-
int no_of_student, student_no;
-
int no_of_uni,uni_start;
-
-
no_of_uni=30;
-
universities university[no_of_uni];
-
no_of_student=50;
-
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: - const int no_of_uni=30;
-
universities university[no_of_uni];
-
const int no_of_student=50;
-
students student[no_of_student];
-
-
//or:
-
-
universities university[30];
-
students student[50];
(i usually do the first, just for the sake of readability, but its really a personal choice.) also, this line - university[i].average_grade=university.[j].max average_grade;
needs to look more like this: - 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 - for(int i=0;i<=30;i++)
-
{
-
university[no_of_uni].name=uni_start;
-
}
-
for(int j=0;j<50;j++)
-
{
-
student[no_of_student].id=student_no;
-
}
that uni_start and student_no do not yet have values. what happened to your input file?
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)
Hope that's of some help
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? - :\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.
Thanks.
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?
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.
- for(int i=0;i<30;i++)
-
{
-
for(int j=i+1;j<30;i++)
-
{
-
if (university[i].average_grade < university[j].average_grade)
-
{
-
max_average_grade=university[j].average_grade;
-
university[j].average_grade=university[i].average_grade;
-
university[i].average_grade=max_average_grade;
-
}
-
}
-
}
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?
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
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
|
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...
|
by: Mary Rosemount |
last post by:
http://www.studentsforacademicfreedom.org/index.html
|
by: JunDa.Huang |
last post by:
I am a university student, How to study program language well ?
|
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)
...
|
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...
|
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;
|
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...
|
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 "-"...
|
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
|
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...
|
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...
|
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,...
|
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...
|
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,...
|
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...
|
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,...
|
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...
| |