comp115/155 assignment 4 (1 Viewer)

redruM

Breathe and Stop
Joined
May 11, 2004
Messages
3,954
Gender
Male
HSC
2003
for loops, search algorithms, you can do it by sorting too, but thats the long/confusing/overcomplicating/my way.
 

redruM

Breathe and Stop
Joined
May 11, 2004
Messages
3,954
Gender
Male
HSC
2003
this is really pissong me off !!!

i have got it to work fine for the first 3 bits[havent attempted the last one yet].
but so that it isnt too much of a hassle i am just using the main fille, ass4.cpp, and just making 4 functions and getting rid of the #include "ass4_funtions.cpp" line.
so thats what i have done so far. that isnt really the exact problem...here is my problem.
lets take the majority() as an example.
Code:
bool Majority(int A[MAX_SIZE], int F, int L, int result)
{
blah blah blah

return true;
OR 
return false;
}
i have to return either true of false right? because in main the thing is going to read:
Code:
if (Majority(A, F, L, result))
{
...
}
if in my majority(), i give result a value, it doesnt come up properly.

i can work around it by saving my result as 'globalresult', which is a global variable and changing the above line of code as
Code:
if (Majority(A, F, L, result))
{
result = globalResult;
...
}
and everything works fine. the problem now is that i only submit my functions file and i cant put the global variables like i would like to when they automark.

anyone who can, please help!!
the fact that i have done the 'hard bit' and now this stupid file shit is pissing me off!

thanks!

btw, sorry if i didnt explain properly, i'm in a rush for work...ask for details and i'll explain when i return. thanks again.
 
Last edited:

doe

Member
Joined
Jan 23, 2004
Messages
751
Gender
Undisclosed
HSC
N/A
bool Majority(int A[MAX_SIZE], int F, int L, int & result)
{
...
result = answer;
return true/false
}
note the & - passing by reference. so in main after a call

Majority(A, F, L, result)

result will contain the correct answer, as it was passed by reference. i can explain this a bit more if you want. does this fix the prob?
 

redruM

Breathe and Stop
Joined
May 11, 2004
Messages
3,954
Gender
Male
HSC
2003
yeh i got it fixed yesteray using same method...reference parameter right?

thanks anyway. :)
 

doe

Member
Joined
Jan 23, 2004
Messages
751
Gender
Undisclosed
HSC
N/A
np

who is the guy in your avatar? i notice a few other people have him as well.
 

toknblackguy

Member
Joined
Nov 1, 2003
Messages
299
Gender
Male
HSC
2003
jezzmo:
if that's your ass_functions file
you're not supposed to have any included libraries
ie remove the #include lines and the using namespace std line
oh..and u do'nt need to declare the functions like that...just have the functinos there - that's all u need
you are only supposed to have ur 4 functions, mjaority, inversion, pairsum and seq one
no main
so you hjust have your 4 functions in that file right
put that file into the same folder as your ass4.cpp file
as long as you haven't modified the ass4 file, it'll compile

cheers
 
Last edited:

ND

Member
Joined
Nov 1, 2002
Messages
971
Location
Club Mac.
Gender
Male
HSC
2003
Basically just sum every possible sequence and find the maximum - not really hard, i just used 3 for loops.
 

redruM

Breathe and Stop
Joined
May 11, 2004
Messages
3,954
Gender
Male
HSC
2003
finished it...

its got problems....hopefuly the testing data doesnt pick it up:p

interesting attatchment./..i didnt get to finish teh commmenting...luckily i stopped when i did. :D
 

jlh

sooner or later...
Joined
Mar 15, 2003
Messages
1,755
Location
Sydney
Gender
Male
HSC
2002
lol redrum....

mine says 22:59 :)

only because i accidentally over- wrote my 'good' copy with proper indentation and comments at around 22.50 :(

i submitted my draft which had no comments and no indentation for some of the functions... :(
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top