What is difference between the following 2 lines….
int temp = (int)(0×00);
int temp = (0×00int);
Post An Answer | 71 Views |
Implement the following function for sorting a linked list of integers in ascending order. The function takes a pointer to the head of the list, and returns a pointer to the head of the sorted list. Your function should use only a constant amount of memory. It’s prohibited to change the value of ListNode, instead ListNodes must be rearranged. struct ListNode{ int value() { return _value; } ListNode *pNext;private: int _value;}; ListNode* SortList(ListNode *pHead){ // Insert your implementation here}
I need this implementation code
Read Answer(1) | 409 Views |
There is a planet more than thousand light years away from earth. They have a big
problem, because they still don’t have a police force and laws, and people are fighting
for land.
There are N (2 <= N <= 1000) people living in this planet. Every person has an
ID number from 1 to N and no two persons will have the same ID number. When they
fight the stronger one wins and the weaker loses. There are M (1 <= M <=
1000) fights going on.
You
are given the strength of each person and the fighting pairs and you have to
determine the winner of each fight.
Input (fight.in)
1. First line contains N and M.
2. Each of the next N Lines contains one integer Pi (1
<= Pi
<= 2000) which is the strength the ith
person.
3. Next M lines contains two integers x and y (1 <= x, y <= N), the ID
numbers of the fighting pair.
Output (fight.out)
Example Input
4 4
1
3
5
2
1 2
2 3
3 4
1 4
Example Output
2
3
3
4
Post An Answer | 218 Views |
People in a certain island want a modern airport. This island has the shape of a
square with side length L (1 <= L <= 10). Its top left corner is at X, Y
(0 <= X, Y <= 50) and the right bottom corner is at X+L, Y+L. They have a
list of N (0 <= N <= 20) existing airports and their locations which they
need to visit frequently. These may be
situated inside this island or outside. Any number of airports can be situated
at the same coordinate position.
The aircraft fly only along grid lines for safety reasons. For example the distance
between (4, 6) and (7, 5) is 7-4+6-5 = 4. The top left corner of the grid is 0,
0. X axis increases from 0, left to right and Y axis increases from top to
bottom from 0. All the airports including the new one are located on grid
points. The total cost of traveling is the sum of the distances to all the other
airports from the new airport. They want the new airport to be located so
that the total cost of traveling is minimized.
Your
task is to find the total cost T of traveling when the airport is built at the
location where the total cost is minimized.
Input (Standard
Input)
1. First Line will be four integers X, Y, L and N.
2. Each of the next N Lines will contain two integers x, y (0 <= x, y
<= 100), the coordinates of an existing airport.
Output (Standard
Output)
Example Input
2 3 2 4
0 0
4 3
5 5
3 4
Example Output
12
Post An Answer | 190 Views |
Crimes are frequent in a planet far away from earth. So the people there have decided to form a
police force and they want the oldest five persons to be the police officers. Because there are many people in this village, they want you to write a program to find the oldest five.
Input (police.in)
1. First line contains N (5 <= N <= 1000).
2. Each of the next N lines contains Ai which is the age of the ith person. The ID number of
the ith person is also ‘i’.
Output (police.out)
Example Input
10
10
3
20
100
50
11
15
25
60
75
Example Output
4
10
9
5
8
Post An Answer | 164 Views |
What is C++ programming?
Read Answers(3) | 668 Views |
Which is the only operator in c++ which can be overloaded but not inherited?
Read Answers(8) | 2,310 Views |
Write a program that reads a positive integer N and then prints an “N times table” containing values up to N * N.
For example, if program reads the value 5, it should pront
5 * 1 = 5
5 * 2 = 10
5 * 3 = 15
5 * 4 = 20
5 * 5 = 25
Read Answers(14) | 1,371 Views |
Can we use recursive in inline function? Why and what happen?
Read Answers(8) | 7,244 Views |
Can you overload a function with the return type?
what is the output of the below.?why?
Class A
{
public:
void func();
};
class B:pubic A
{
void func(int a);
};
int main()
{
B derv;
derv.func();
}
Read Answers(20) | 15,532 Views |