By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,949 Members | 889 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,949 IT Pros & Developers. It's quick & easy.

assignment

P: 1
IN C++ or JAVA.PLEASE ,DO NOT WRITE ANY INPUT AND OUTPUT.DO NOT WRITE ANYTHING TO THE CONSOLE.

1.Write a function that accepts two character arrays as input and returns the one that is greatest in lexicographic (dictionary) order. Note the input is two character arrays, not two Strings! If the two arrays are equal return the first one. If either array is null, return null.

The signature of the function is:
char[ ] f(char[ ] a1, char[ ] a2)

Examples

{'d', 'o', 'g'} and {'c', 'a', 't'} returns {'d', 'o', 'g'}
{'a', 'b', 'd'} and {'b', 'b', 'c'} returns .{'b', 'b', 'c'}
{'d', 'i', 'g'} and {'d', 'o', 'g'} returns {'d', 'o', 'g'}
{'d', 'o', 'g'} and {} returns {'d', 'o', 'g'}
{'c', 'a', 'r'}, {'c', 'a', 'r', 't'} returns {'c', 'a', 'r', 't}
{'c', 'a', 'r'} and {'c', 'a', 'r'} returns {'c', 'a', 'r'}
{} and {} returns {}
{'a'} and {} returns {'a'}
{} and {'a'} returns {'a'}
null and {'a'} returns null
Jun 18 '07 #1
Share this Question
Share on Google+
2 Replies


sicarie
Expert Mod 2.5K+
P: 4,677
akowuah-

Please read the Posting Guidelines which request, amongst other things, attempting the problem and posting what you have tried, as well as posting in the C++ Forum section.

Thanks!

::Edit:: I have moved this to the proper section, but please post what you ahve tried and a more specific description of the issue you are stuck on.
Jun 18 '07 #2

100+
P: 208
IN C++ or JAVA.PLEASE ,DO NOT WRITE ANY INPUT AND OUTPUT.DO NOT WRITE ANYTHING TO THE CONSOLE.

1.Write a function that accepts two character arrays as input and returns the one that is greatest in lexicographic (dictionary) order. Note the input is two character arrays, not two Strings! If the two arrays are equal return the first one. If either array is null, return null.

The signature of the function is:
char[ ] f(char[ ] a1, char[ ] a2)

Examples

{'d', 'o', 'g'} and {'c', 'a', 't'} returns {'d', 'o', 'g'}
{'a', 'b', 'd'} and {'b', 'b', 'c'} returns .{'b', 'b', 'c'}
{'d', 'i', 'g'} and {'d', 'o', 'g'} returns {'d', 'o', 'g'}
{'d', 'o', 'g'} and {} returns {'d', 'o', 'g'}
{'c', 'a', 'r'}, {'c', 'a', 'r', 't'} returns {'c', 'a', 'r', 't}
{'c', 'a', 'r'} and {'c', 'a', 'r'} returns {'c', 'a', 'r'}
{} and {} returns {}
{'a'} and {} returns {'a'}
{} and {'a'} returns {'a'}
null and {'a'} returns null
If you're not supposed to write any input how does the function get the char arrays?
Jun 18 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.