473,385 Members | 1,588 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

assignment

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
2 962
sicarie
4,677 Expert Mod 4TB
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
Silent1Mezzo
208 100+
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

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

Similar topics

23
by: Paul Rubin | last post by:
OK, I want to scan a file for lines matching a certain regexp. I'd like to use an assignment expression, like for line in file: if (g := re.match(pat, line)): croggle(g.group(1)) Since...
10
by: Andrew Koenig | last post by:
It has been pointed out to me that various C++ books disagree about the relative precedence of ?: and the assignment operators. In order to satisfy myself about the matter once and for all, I...
5
by: CoolPint | last post by:
It seems to me that I cannot assign objects of a class which has a constant data member since the data member cannot be changed once the constructor calls are completed. Is this the way it is meant...
16
by: Edward Diener | last post by:
Is there a way to override the default processing of the assignment operator for one's own __value types ? I realize I can program my own Assign method, and provide that for end-users of my class,...
9
by: Rick N. Backer | last post by:
I have an abstract base class that has char* members. Is an assignment operator necessary for this abstract base class? Why or why not? Thanks in advance. Ken Wilson Amer. Dlx. Tele,...
1
by: Jon Slaughter | last post by:
I have a chain of classes(i.e., a series of classes each containing an array of the next class). Each class has array like access. struct Myclass1 { vector(Myclass2) _Myclass2; Myclass2&...
166
by: Graham | last post by:
This has to do with class variables and instances variables. Given the following: <code> class _class: var = 0 #rest of the class
6
by: Neil Zanella | last post by:
Hello, I would like to know whether the following C fragment is legal in standard C and behaves as intended under conforming implementations... union foo { char c; double d; };
35
by: nagy | last post by:
I do the following. First create lists x,y,z. Then add an element to x using the augumented assignment operator. This causes all the other lists to be changed also. But if I use the assignment...
20
by: TimeHorse | last post by:
I would like to gauge interest in the following proposal: Problem: Assignment statements cannot be used as expressions. Performing a list of mutually exclusive checks that require data...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.