发7道变态码工题,大家帮忙解解,3包子一题# JobHunting - 待字闺中
a*g
1 楼
Please read and follow all instructions before beginning. For questions 1-4,
answer any two questions in any of the following programming languages (C /
C++ / Java / C# / VB / VB .NET). Please read questions carefully and answer
them to the BEST of your availability.
1. Write a function that takes as arguments two singly linked lists(unsorted
) and returns a singly linked list with nodes that exist in only one of the
input linked lists.
2. Write a function that returns the greatest product of five consecutive
digits in a 1000-digit number.
3. 1-Jan-1901 was a Monday.
The following months have exactly 30 days : April, June, September, November
The following months have exactly 31 days : January, March, May, July,
August, October, December.
February has 28 days except on leap years when it has 29 days.
A leap year occurs on any year evenly divisible by 4, but not on a century
unless it is divisible by 400.
Write a function that takes as an argument an EndDate and counts the number
of Sundays that fall on the first of the month between the dates 1-Jan-1901
and EndDate
4. Given a 2-dimensional array of integers, write a function to find cells
with values 3 through 7 inclusive, and for their horizontal and vertical
neighbors, return a single total of their values, counting each neighboring
cell towards the total once.
Example: the following 6*3 grid would produce a total of 18 by summing up
the 1's, 4's, and 5's:
9 1 9 1 1 9
1 6 1 4 5 1
9 1 9 1 1 9
For questions 6 and 7, choose just one question to answer in any one of
these object oriented languages: (C++/ Java/ C#/ VB.NET) When you are
finished please write finished at the end of the document and sign out.
Thank you for your time.
(Include the code below as part of this question)
6. A single processing queue is shared by one or more producer threads and
one or more consumer threads. Fill in the code for the producer loop and the
consumer loop.
interface IDataAccess
{
//Retrieves a batch of items to process
List GetItemsBatch();
}
interface IConsumable
{
//Processes an item
Process();
}
Queue ProcessingQueue;
class Producer
{
private IDataAccess DataAccess;
public void ProducerLoop()
{
while (running)
{
List batch = DataAccess.GetItemsBatch();
//Insert Code
}
}
}
class Consumer
{
public void ConsumerLoop()
{
while (running)
{
//Insert Code
}
}
}
(Include the code below as part of this question)
7. Implement this interface as efficiently as possible using a binary tree
to store the data. The tree does not have to be balanced.
//Represents a non-generic collection of objects that can be individually
accessed by index. Indicies are zero-based and contiguous.
interface IListLite
{
//Appends an item after the last index of the list, preserving the order of
existing items.
void AppendItem(object item);
//Inserts an item at the specified zero-based index, preserving the order
of existing items.
void InsertItem(object item, int index);
//Retrieves the item from the specified zero-based index.
object GetItem(int index);
//Retireves the current number of items in this list.
int GetItemCount();
}
answer any two questions in any of the following programming languages (C /
C++ / Java / C# / VB / VB .NET). Please read questions carefully and answer
them to the BEST of your availability.
1. Write a function that takes as arguments two singly linked lists(unsorted
) and returns a singly linked list with nodes that exist in only one of the
input linked lists.
2. Write a function that returns the greatest product of five consecutive
digits in a 1000-digit number.
3. 1-Jan-1901 was a Monday.
The following months have exactly 30 days : April, June, September, November
The following months have exactly 31 days : January, March, May, July,
August, October, December.
February has 28 days except on leap years when it has 29 days.
A leap year occurs on any year evenly divisible by 4, but not on a century
unless it is divisible by 400.
Write a function that takes as an argument an EndDate and counts the number
of Sundays that fall on the first of the month between the dates 1-Jan-1901
and EndDate
4. Given a 2-dimensional array of integers, write a function to find cells
with values 3 through 7 inclusive, and for their horizontal and vertical
neighbors, return a single total of their values, counting each neighboring
cell towards the total once.
Example: the following 6*3 grid would produce a total of 18 by summing up
the 1's, 4's, and 5's:
9 1 9 1 1 9
1 6 1 4 5 1
9 1 9 1 1 9
For questions 6 and 7, choose just one question to answer in any one of
these object oriented languages: (C++/ Java/ C#/ VB.NET) When you are
finished please write finished at the end of the document and sign out.
Thank you for your time.
(Include the code below as part of this question)
6. A single processing queue is shared by one or more producer threads and
one or more consumer threads. Fill in the code for the producer loop and the
consumer loop.
interface IDataAccess
{
//Retrieves a batch of items to process
List
}
interface IConsumable
{
//Processes an item
Process();
}
Queue
class Producer
{
private IDataAccess DataAccess;
public void ProducerLoop()
{
while (running)
{
List
//Insert Code
}
}
}
class Consumer
{
public void ConsumerLoop()
{
while (running)
{
//Insert Code
}
}
}
(Include the code below as part of this question)
7. Implement this interface as efficiently as possible using a binary tree
to store the data. The tree does not have to be balanced.
//Represents a non-generic collection of objects that can be individually
accessed by index. Indicies are zero-based and contiguous.
interface IListLite
{
//Appends an item after the last index of the list, preserving the order of
existing items.
void AppendItem(object item);
//Inserts an item at the specified zero-based index, preserving the order
of existing items.
void InsertItem(object item, int index);
//Retrieves the item from the specified zero-based index.
object GetItem(int index);
//Retireves the current number of items in this list.
int GetItemCount();
}