Programming exerises

Hello guys, we've started with C++ at college and I'm really struggling with structuring my programs and just imagining how my program is going to have to be set up from A-Z when I read the exercise. I try to break it down into smaller problems, but I always get stuck somewhere, either with failing to understand how to write a code that will do what I want it and then implement it into the bigger picture.

We've "covered" theory behind loops, arrays and now going into sort algorithms, but I feel like I've learned nothing (might be also due to just having no time to learn programming and having to do other assignments all the time).

I feel like something is missing in my understanding, but I can't point it out what exactly it is, other than "do more exercises in 10 different ways about every topic we've covered".

Is there any good site with explained solutions for C++? I don't know what else to do, even teacher fails to explain shit to me at exercises, but the other guy teaching classes is just horrendous.

Attached: 1543410798390.jpg (804x789, 364K)

Other urls found in this thread:

github.com/tuvtran/project-based-learning
github.com/AlgoryL/Projects-from-Scratch
github.com/danistefanovic/build-your-own-x
aosabook.org
twitter.com/SFWRedditVideos

>exerises

never gonna make it

Man, I can write a GUI in C++ or Python with being a code monkey and googling everything, that's not a fucking problem. However, I don't want to be a code monkey pajeet and actually understand what the fuck is happening behind the code and the logic.

If you never went to college and think it's a meme, then that's your problem. Everybody can become a programmer today over night by copying shit off google and proclaiming themselves to know what they are doing.

And yes, exercises are a good way to build a strong foundation and go form small steps to bigger steps. If you somehow got good at programming by staring at code and just implementing all the concepts into various context of assignments, then congrats, you are the 1%.

programs = data structures + algorithms

think about your data structures first
simple structs suffice

now write functions that operate on those data structures, can you do that? do you have an example of something you're trying to accomplish?

Just do bigger exercises (ones that require like 100 lines of code), because you won't really learn how to structure your program by doing small exercises. Every time you reach a point where you realize your design is completely shit and you should have done things X way you learn something.

Yes, example of one of the assignments.

Attached: 12.jpg (1232x743, 156K)

OP here, now tell me how the fuck is one supposed to write a program about this, after having just basic lectures about loops and arrays, etc.. I know everybody says the same that you have to learn how to program on your own, but still, the fuck.

Retrospectively, I believe the way is to consume enough information and one day it just clicks for you (magic), not even shitting you. There is so much to know and exercises usually get you nowhere forward. Sure you should do them because doing is the strongest way or learning.

I guess, I know what you mean. I feel like I've come far in certain areas already, but the pressure and intensity of topics/concepts/assignments and learning is just insane. I feel like a monk starting at computer screen for 12 hours sometimes already and it's 2 months in CS meme degree, that turned out not to be meme at all.

The phrase you're after is 'software engineering.' There are books on the topic.

Software has three parts:
1. Data
2. Algorithms
3. DOCUMENTATION

what a retarded assignment, it basically forces you to write bad practice C++
a) why the hell would you use a 2d array to represent that? a 1d array/vector of structs is the obvious choice
b) forces you to hard code a predefined array, completely pointless
c) with a vector of structs the appropriate way is to write a sort algorithm or use std::sort (in real life) with an operator overload for

breaking it down to smaller problems and decisions:

a) deciding on data structure for the gradebook
Assignment really puts it terribly as it explicitly tells you to use 2-dimensional array. In statically typed language where each column as different type, this is weird way to put it. I would suggest to make a struct (or class) Row (or Student or whatever you want to name it) with each column as member field - the whole gradebook is then just a 1-dimensional array of rows.

b) write a function that generates new Row and returns it
subproblems here: random integer from [0,100], pick a random name from array of names (can also be pick number number frm [0,len(names)) ), merge 2 strings into one. Construct the Row with them and return it. I'm confused here about the sequential number. It could be one of following: index in array or incrementing ID of student. I would guess it should be the latter - either hold a global state or take the Seq.number as the only input.

c) Sorting array by specific key
Now I don't know if you can use a sort function from standard library, but providing custom comparison function is a common thing (it should return a.oc > b.oc).

d) printing rows with special rules
You should not modify the rows in any way to accomplish this, no changing of OC fields is happening. Write some display function that takes a row and reports it to (probably standard output) following given rules. Since the gradebook is now sorted, this should be performed as simple for-each loop and calling the display function on each entry.

e) calculating average and finding sudent closest to average
I didn't quite get the ", who passed the exam". Do this in 2 passes - first calculate the average, second find the closest person. It's the same as searching max or min in array, except you are searching min of abs(oc - average)

that's how a sane person would solve it, but OPs teacher could subtract points for not following instructions

Guys main question is how or which site provides step by step learning so I teach myself to learn this, don't do my homework.

Or am I supposed to just, learn as much as I can until it clicks.

part of the process is to learn as much as you can until it clicks, it takes time to process and after a certain amount of hours you adapt

you could try something like codewars, solve a kata every day

i would also recommend starting your own little project on the side with something you're motivated to work on (it's impossible to enjoy the kind of exercise you showed)

don't expect that your teacher will teach you the right way to do things, he might well teach you to become a bad programmer, find out yourself

I'm not saying all of them are good or worth doing, but I hope it helps you in some way
github.com/tuvtran/project-based-learning
github.com/AlgoryL/Projects-from-Scratch
github.com/danistefanovic/build-your-own-x
aosabook.org

ty, I have two side projets, one GUI in python and other GUI in C++ and I'm doing fine and understand how code works, even though I copy a lot, but I still learn new things every day and at least I can write a GUI that has buttons and those buttons functions, etc.. something useful.

However, then we get assignments like I showed and I just fucking freeze, because I don't even know where to start.

this is not to help you with the homework, but to show you how this would typically be solved in C++ in a real application
all it does is generate a data structure and sort according to oc, the rest of the items can easily be solved from this base

#include
#include
#include
#include

struct entry
{
std::string name;
int kv, rv, vi, oc;
};

int
gen_random()
{
return rand() % 101;
}

int
main(void)
{
const int n_students = 166;
std::vector gradebook;

for(int i = 0; i < n_students; ++i)
gradebook.push_back(entry{"name" + std::to_string(gen_random()),
gen_random(),
gen_random(),
gen_random(),
gen_random()});
std::sort(
gradebook.begin(),
gradebook.end(),
[](const entry& lhs, const entry& rhs) { return lhs.oc > rhs.oc; });

for(auto e : gradebook)
std::cout

I get it, I just didn't know what to point out that was missing in my learning.

I guess it's time to wake up earlier and work harder and longer hours. It's just insane workload and if I'm not doing assignments and going to lectures, I'm learning. The fucked up part is that assignments take up few days to do usually and you can't plagiarize or you end up being kicked out of school.

So yeah, it's like I'm getting a bonus when I have a time to study math for example, since other time is spent on fucking assignments. Idk what to think of it, I asked myself few times already if it is that I'm not studying enough or if this first two semesters are really set up to be a filter and only the best get through. It's like there's no days off, if you actually want to make something out of it. I feel like I was working less hard and less stressfull when I had a full time physical job that I did 6x per week for 8 hours per day than now that I'm in college and have 24hours per day free to do anything.

Not sure what to think of it. I like the filter appeal, but too much is too much sometimes and you end up sacrificing spending time on some retarded assignments and then lack the study time for things that matter, like programming and math, despite already working all day everyday for 7 days per week.

I don't know how Jow Forums or /sci/ thinks CS degree is meme, it's the opposite in my case.

Attached: lol.jpg (225x225, 6K)

They think it's a meme because they don't have CS jobs.