C++ Challenges

Hi,
I think its a great way to learn a programming language by solving programming challenges in the language you are learning. However there not much interesting programming challenges around there on the web for "Beginners". Why not make and post challenges in this thread?

--
Here is mine:
Get 9 integer inputs from the user and store then in a 2D array of width 3, height 3. Then display the numbers in a matrix form.

Example input:

1
2    
3    
4    
5    
6    
7    
8    
9    


Example output:

|1 2 3|
|4 5 6|
|7 8 9|
Last edited on
I agree that challenges are always a good idea but I think Lounge is a better place for this (as you aren't asking for any advice). I suggest you edit your topic and move it there.
Also, these are rather "exercises" then "Challenges", since challenge should be challenge, and if you are not beginner, this one isn't a challenge :)
Write the following program:


Challenge 1:

Knowledge required:
- Basic/simple sorting algorithm (hint: recursion)
- (C++ object) Strings
- (C++ object) Vectors
- (C++ object) ifstream and ofstream

It's pretty basic. :)

You must sort a list of strings in alphabetical order (a-z, non-case sensitive).

You must them save them to a file, erase them from memory, and completey reload them from the file. You will insert and remove any number of strings while maintaining the alphabetical order of the list.


Challenge 2:

- (C++ function) getline(istream&, string&, const char&) getline with a specified delimiter
- (C++ Object) strings
- (C++ Object) Vector (optionally: arrays or linked lists will do as well)
- (C++ Object) ifstream and ofstream
- ASCII (American Standard Code for Information Interchange) character codes

You must save a list to a file without using endl to separate strings. You will save each string in a list of strings to a file using a delimiter to separate each string. Once you do this, you will erase the list, and completely load all of the data from the file back into the list (or vector) in the same order it was in before you saved it.

Optionally, you can modify challenge 1 for this.


Have fun! :D
Topic archived. No new replies allowed.