Author Topic: C++ Exercises?  (Read 11243 times)

0 Members and 1 Guest are viewing this topic.

Offline CommanderDJ

  • Software engineer
  • 210
    • Minecraft
Can anyone link me to some good C++ exercises? I've found that I'm learning stuff pretty quick and I want to put my skills to the test. Thanks!

CommanderDJ
[16:57] <CommanderDJ> What prompted the decision to split WiH into acts?
[16:58] <battuta> it was long, we wanted to release something
[16:58] <battuta> it felt good to have a target to hit
[17:00] <RangerKarl> not sure if talking about strike mission, or jerking off
[17:00] <CommanderDJ> WUT
[17:00] <CommanderDJ> hahahahaha
[17:00] <battuta> hahahaha
[17:00] <RangerKarl> same thing really, if you think about it

 

Offline Thaeris

  • Can take his lumps
  • 211
  • Away in Limbo
http://www.cplusplus.com/

^Invaluable resource. Exercises? Learn I/O libraries to make a program spit out a text file - that's a great higher-level exercise to delve into. :)
"trolls are clearly social rejects and therefore should be isolated from society, or perhaps impaled."

-Nuke



"Look on the bright side, how many release dates have been given for Doomsday, and it still isn't out yet.

It's the Duke Nukem Forever of prophecies..."


"Jesus saves.

Everyone else takes normal damage.
"

-Flipside

"pirating software is a lesser evil than stealing but its still evil. but since i pride myself for being evil, almost anything is fair game."


"i never understood why women get the creeps so ****ing easily. i mean most serial killers act perfectly normal, until they kill you."


-Nuke

 

Offline CommanderDJ

  • Software engineer
  • 210
    • Minecraft
Thanks! I will get into that.
[16:57] <CommanderDJ> What prompted the decision to split WiH into acts?
[16:58] <battuta> it was long, we wanted to release something
[16:58] <battuta> it felt good to have a target to hit
[17:00] <RangerKarl> not sure if talking about strike mission, or jerking off
[17:00] <CommanderDJ> WUT
[17:00] <CommanderDJ> hahahahaha
[17:00] <battuta> hahahaha
[17:00] <RangerKarl> same thing really, if you think about it

 

Offline The E

  • He's Ebeneezer Goode
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 

Offline Spicious

  • Master Chief John-158
  • 210
You might find the attached interesting/challenging.

[attachment deleted by ninja]

 

Offline CommanderDJ

  • Software engineer
  • 210
    • Minecraft
There's also this entry-level challenge on the SCP Mantis.

What do you mean by entry-level challenge?

EDIT: Like, I get what it is, but does this have possible implications for future involvement for whoever solves it?
« Last Edit: August 20, 2010, 11:07:51 pm by CommanderDJ »
[16:57] <CommanderDJ> What prompted the decision to split WiH into acts?
[16:58] <battuta> it was long, we wanted to release something
[16:58] <battuta> it felt good to have a target to hit
[17:00] <RangerKarl> not sure if talking about strike mission, or jerking off
[17:00] <CommanderDJ> WUT
[17:00] <CommanderDJ> hahahahaha
[17:00] <battuta> hahahaha
[17:00] <RangerKarl> same thing really, if you think about it

 

Offline The E

  • He's Ebeneezer Goode
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Only if you want it to be. The point is that the solution for that problem is easy enought to implement for new guys.
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 
Coming from an engineering background, and having spent more time around CS students and algorithms competitions than I'd care to admit, I'd suggest that programming is only a small part of the puzzle.
A larger part of the puzzle is thinking about the algorithms that you're trying to implement.

http://uva.onlinejudge.org/ is a collection (and automated judging system) of problems from the ACM ICPC finals, and they do range in difficult from solve on an envelope to 'ask someone at Google'.

I suggest trying to work your way through them - you will learn more about programming by doing that than by just writing up classes that do very simple operations.
STRONGTEA. Why can't the x86 be sane?

 
There's also this entry-level challenge on the SCP Mantis.

I decided to give it a go, how does this look? (see attached alphacolors.zip, not sure how to create .diff or .patch in VC). In the UI white should change to black and blue should change to red.

As requested in mantis, it looks up colors.tbl and changes whatever colour specified. But you will need to specify all three colours if you do.
Some notes:

  • You can only change the colours specified in *Color_netplayer[]
  • Parsing is based off existing parsers such as in ship.cpp and ai_profiles.cpp
  • New array for the colour names, *Color_names[], will match what is written in the table, and should correspond exactly with *Color_netplayer[]
  • New constant #define NUM_COLORS 20, so the arrays can be used in loops
  • gr_init_alphacolor() is done twice on whatever custom colors specified in table, it worked for me but I don't know too much about what it does (if it works on different machines etc.)
  • Is the string concatenation adequate? (I learned C++ skipping C)

[attachment deleted by admin]

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Didn't notice this until now. I'll take a look at it today.

EDIT : To be honest I'd have been tempted to move all the hardcoded colours to Def_Files. Not entirely sure about your string handling either. Might want someone more used to it to double check it too.
« Last Edit: November 21, 2010, 04:33:38 am by karajorma »
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 
Ok, well I was aiming to modify only one file (set by taylor in mantis). And I guess NUM_COLORS would also be better off in alphacolors.h anyway.  Ill make some changes as to what you suggested (didnt notice def_files before, still new to the fs code) Will edit this post when I'm finished making changes.

EDIT: Done. 3 files now changed: alphacolors.cpp, alphacolors.h, and def_files.cpp

Changes:
  • Tweaked parsing a little (use strncpy first then strncat)
  • New function void parse_colors_tbl(char* filename) to do the tbl parsing, again with coding and comments stolen borrowed from ai_profiles.cpp
  • Default table stored in def_files.cpp as Default_colors_table, still for netplayer colors only
  • Black and light pink are still initialized manually, since they don't exist in Color_netplayer[]
  • alphacolors.h updated to reflect changes

Unlike the previous solution its a bit less efficient (loops through the color_netplayer array for each entry in the default table). Does this matter too much?

[attachment deleted by admin]
« Last Edit: November 22, 2010, 04:24:38 am by Waistless »