[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Desperation
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /r9k/ - ROBOT9001

Thread replies: 26
Thread images: 2
File: 1438086560313.gif (63 KB, 320x303) Image search: [Google]
1438086560313.gif
63 KB, 320x303
Would an anon out there like to do my programming task for me? It's simple if you're good at programming or intermediate level. You'd probably finish it very quickly. I don't have time for it, I have so much crap to do.

If you're interested, just drop an email.
>>
>>27279928
>want to help me not fail my course?
Nah, enjoy.
>>
What is problem
>>
say what about first maybe
>>
>>27279928
I only know a small amount of C++, what is the problem?
>>
>>27279987
How do parameters for functions work? I'm working in C.

>>27280039
Basically you're given a grades.txt file in CSV format and are expected to calculate the average, max, and the number of people that failed using functions. They give you one global variable to use which is a two dimensional array called grades[1001][101], where 1001 is supposed to be the number of students and 101 is supposed to be the number of assignments. However, there are 1000 students and 100 assignments, the array is constructed to start from index 1 if you wanted to do that. (starting from index 0 is weird if you're talking about assignments and students)

so far I have a while loop and a for loop within that while loop to read in all the grades from the input file until I reach the end of the file and after that I have my calls for the functions present. How do I return the values for those functions to one function that I will use to output? Also, how do you calculate the average and max from grades[1001][100]?
>>
>>27280171
Generally I calculate average by adding all of the values in an array up and keeping a separate int counter for numbers of entries then dividing by that counter
At the same time you can make a value called max for whatever the grade is then a loop that has an if so that when the value read is greater than the max, max is then set to the current read number
>>
File: 1455318159588.jpg (51 KB, 463x509) Image search: [Google]
1455318159588.jpg
51 KB, 463x509
>tfw 21
>mfw will never learn how to program since I'm too old even though I want to
>>
>>27280310

You can start now and enjoy it as a hobby. Of course it's most likely too late to do the really worthwhile stuff, but you can do things for your own enjoyment or do the superficial stuff like become a "web developer".
>>
>>27280171
Eh doesn't seem that interesting but maybe i'l do it. I have very little to do. I also want to procrastinate one what I have to do.
[email protected]
Will send the code back to you on the email you sent it at.
Also I'd appreciate your code since reading the file is the most boring bit. (also makes it less plagiarism)
>>27280286
You could do that if you don't have floating point precision/integer overflow concerns. Accumulating an average is likely better in most cases where performance isn't a major concern (like here). That is
>count them
>take each number and divide by total number of elements
>add it to your average variable
Works because (a+b+c)/3 == (a/3)+(b/3)+(c/3).
This way you can't ever get an overflow because your accumulated average can't exceed the data type you store it in. And floating point precision (always a problem) will be a very small problem because even if you had FLOAT_MAX in every cell you'd still get as close as you could hope to. Unlike the accumulated sum which may even stop adding a lot of the elements.

And the code complexity is about the same.
>>27280310
Never too late. If you look at the quality of code that people produce pre-18 you find that they're woefully bad. They do learn some useful stuff but I've been programming since 12 technically, on and off. And ages 17-23 have by far outshined the earlier years. They're negligible now really.

Unless you're some prodigy you won't even be noticeably different to other code monkeys.
>>
>>27280437
>overflow
Huh, I never considered that, that is a good point I guess that method wouldn't work in a commercial environment where there's millions of units of things
>>
>>27280457
Yeah it's really something you tend to miss.
If I knew my numbers weren't gonna hit INT_MAX or whatever your method is certainly better. Because I have n times additions and n times divisions. While you have n times additions and one division. Both are equally easy to multithread/SIMDize. Your method is likely twice as fast at least.
>>
>>27279928
Oh yeah look up the stupid question general /sqt/ in /g/ for future code fuckery because I know stack overflow and those shitty places take weeks to respond
>>
>>27280437
Thank you anon, I sent the email to you with my code along with instructions. It might not be correct.
>>
>>27280521
Not only that but if you have anything but the most elementary questions they often make inaccurate assumptions that aren't corrected for months.

Generally the most friendly people and most helpful are freenodes language specific IRC's.
>>27280530
When is it due? Just approximately.
I'll be leaving comments in the code to correct yours and explain mine. If I do it. So don't just turn it in.
>>
>>27280559
It's due tonight at 11:59 pm. And yeah, I don't expect you to do the whole thing for me on such short notice. Maybe just look at my while and for loop in my main function and leave a comment if you don't feel like programming this garbage. Again, literally ANY help is appreciated.
>>
>>27280597
CET? Timezones man.
>>
>>27280617
Of course, EST. Also, everything is in C just to let you know.
>>
>>27280627
I did some looking and you're like way off. I'l start writing something.

But look at this in the meanwhile so you can learn stuff. Ask any questions you may have.
http://pastebin.com/25Q14FDi
(probably also made some mistakes)
>>
>>27280171
>Also, how do you calculate the average and max from grades[1001][100]?

You can create 2 functions each returning a double and take in a pointer to the array, the heigh and the width.

Something like

double average(int *array, int h, int w)

After that you use 2 nested for loops to add all grades together (maybe error checking if that is required) and then you return that number divided by h*w.
Make sure the variable you use to add up the numbers is a float or double.

Max works very similar you start witg a variable which is zero, check all values and every time you find one that is bigger you replace it.

If you want I can write you the functions.
>>
>>27281359
http://pastebin.com/DijD6dBG
Almost done here. Sorry for being lazy. Probably worries you a lot.
>>
>>27280530
I've replied with the completed assignment and some food for thought.
>>
>>27279928
>If you're interested, just drop an email.
Sent ;)
>>
>>27280310
if you start now you can still be a baller by 30
>>
>>27279928
Geez, at least give us some incentive, like boypucci pics
>>
>you will never tutor a qt programmer girl for nude/qt pics
Why is life so cruel?
Thread replies: 26
Thread images: 2

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.