IT/Software career thread: Invert binary trees for dollars.

a_skeleton_03

<Banned>
29,948
29,763
So by googling my assignment I found this code.

It doesn't quite meet my needs and I am working on it, also transitioning it from C to C++ because I feel more comfortable in C++ so far.
 

a_skeleton_03

<Banned>
29,948
29,763
Okay working it out a little bit more.

I think I have a lot of the moving parts where I want them to be, this is a bastardization of what Tenks posted.
 

Tuco

I got Tuco'd!
<Gold Donor>
46,831
78,476
congratulations! If you ever wonder what this object oriented nonsense is about, here's what your project would look like with classes and structs and some STL objects.

 

a_skeleton_03

<Banned>
29,948
29,763
What do you guys think about my program though? Too crude? Just efficient? Some crazy memory leak?

It's already submitted for grade so this is the point of learning for me.

After its all done I must say that I would never willingly code on demand for a job or class. I might try to play around with stuff though now that I have half of a grasp on it.
 

a_skeleton_03

<Banned>
29,948
29,763
What do you guys think about my program though? Too crude? Just efficient? Some crazy memory leak?

It's already submitted for grade so this is the point of learning for me.

After its all done I must say that I would never willingly code on demand for a job or class. I might try to play around with stuff though now that I have half of a grasp on it.
 

Tuco

I got Tuco'd!
<Gold Donor>
46,831
78,476
It's fine. It looks like code written by someone doing it for an array learning assignment.
 

Noodleface

A Mod Real Quick
38,245
15,030
My only critique is there's not much input validation, I don't know if an intro to programming professor would knock you for that
 

Asshat wormie

2023 Asshat Award Winner
<Gold Donor>
16,820
30,968
What do you guys think about my program though? Too crude? Just efficient? Some crazy memory leak?

It's already submitted for grade so this is the point of learning for me.

After its all done I must say that I would never willingly code on demand for a job or class. I might try to play around with stuff though now that I have half of a grasp on it.
My (fairly tiny) nitpick would be the usage of "break". The way you used it should be avoided. A single exit point in a loop is better for readability IMO.
 

a_skeleton_03

<Banned>
29,948
29,763
My (fairly tiny) nitpick would be the usage of "break". The way you used it should be avoided. A single exit point in a loop is better for readability IMO.
Yeah probably not elegant. I needed a way out without introducing a ton more lines.

Funny story I had it done the following way and it took me a bit to find out why I was losing the information from the last person entered.

if (more == 0) break;
x++;

Well of course it wasn't working right because it was breaking before it could increment. Total brain dead moment there but I figured it out.
 

Asshat wormie

2023 Asshat Award Winner
<Gold Donor>
16,820
30,968
Yeah probably not elegant. I needed a way out without introducing a ton more lines.

Funny story I had it done the following way and it took me a bit to find out why I was losing the information from the last person entered.

if (more == 0) break;
x++;

Well of course it wasn't working right because it was breaking before it could increment. Total brain dead moment there but I figured it out.
Look at how tuco's code exits the loop. That's more clear to read through. Also the brain dead moment? Welcome to writing code!
 

Vinen

God is dead
2,789
495
My point was that you don't need -- and oftentimes shouldn't get -- a CS degree to get into tech for the most money. I have a CS degree and work in IT consultancy. I worked in product dev previously. Everyday I meet people in this industry who majored in not just something that's not CS, but other things like history or polisci.

So the advice I was trying to give was that to only get a CS degree if you actually want to code. There are better, easier ways to make more money in tech without computer science, which is something many people aren't aware of.
It's much harder to break in if you lack a CS Degree.
You have to prove you don't suck ahead of time.
 

Noodleface

A Mod Real Quick
38,245
15,030
I don't mind using breaks to exit a loop in that type of condition, it's all personal preference. As long as it makes sense.