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
2 962
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.
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?
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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,...
|
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,...
|
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&...
|
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
|
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;
};
|
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...
|
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...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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
|
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...
|
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...
|
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...
|
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,...
|
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...
| |