a problem in Matrices


Write a complete C++ program that declares a character matrix of size (7×30). After that create and call the following functions:
1. a function that receives the character matrix and the number of rows, then, it asks the user to enter names from keyboard to be stored in the matrix.
2. a function that receives the matrix and the number of rows, then, it prints these names on screen (each name in a separate line)
3. a function that receives the matrix and the number of rows and returns the number of names that starts with ‘d’
4. a function that receives the matrix and the number of rows and returns the number of names that starts with capital letters.
5. a function that receives the matrix and the number of rows. Then arrange the names in ascending order according to the names’ lengths.


but my problem is point number five !

I hope that you can help
thanks
i don't know how to ascend them
Try writing out some matrices by hand (small ones, don't take the 7X30 one head on) and then manually arrange the names in ascending order according to the name's lengths. Now go back and look at how you did it. Then translate your actions into pseudocode. Then that can be translated into c++ and then compile and run it, work out the kinks, etc.

bob john
james jo

something like that. And then you can just go through the matrix and find the length of each name and whatever is the shortest, make that the first, and then if you come upon a shorter one, then make THAT one the first, and so on. So you get bob = 3, so that's your first, then john = 4, so that goes after 3, then james = 5 so that goes after 4, then jo = 2, so put that before 3. This is the easiest, most easy to understand, way that I can think of writing that function.
does that mean you need to arrange it to alphabetical order?
If i got the problem correctly then:

you just need to compare character by character and the algorithm is just like arranging numbers from least to greatest and vice versa...
drummin2somebeats : thank you but i tried to figure it out on paper and that didn't work ! .. i hope that you know the C++ code for that .

markXD07 :
No , my problem is to ascend the names . like what is written in the comment previous .

Topic archived. No new replies allowed.