473,491 Members | 1,885 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

need your help (two urgent tasks)

Hello, Everybody!

Ok, I urgently need the solution for a following task in C++. This is the task from programmers contest,
so I believe somebody have a solution for it.
I need either a full source code or a simple description of algorithm to solve this task.

thank a lot in advance.

Unit Conversion
A (measurement) unit is here represented by a single word containing only lower-case letters. All
units are written as singular both in input and in output. A conversion fact relates the size of two
units.
You are to convert a quantity in one unit to the equivalent quantity in a different unit using only
a given set of conversion facts. These conversion facts are self consistent; there is never more
than one conversion chain from any unit to any other unit.

Input
The input will start with a number of lines, each containing a conversion fact in the form:
<v1> <u1> = <v2> <u2>
The elements <v1> and <v2> are positive real numbers (a sequence of decimal digits, containing
at most one decimal point), and <u1> and <u2> are strings containing only lower case letters
representing the name of a unit. The elements are separated by single spaces. The conversion fact
asserts that the quantity <v1><u1> is equal to the quantity <v2><u2>.
There will then a number of lines each representing a conversion request in the form:
<v3> <u1> = ? <u2>
The elements <u1> and <u2> are again unit names, which may or may not have occurred in the
conversion facts. All elements on the line are separated by single spaces (the equality sign and
question mark are surrounded by single spaces too). The end of data is represented by end-offile.

Output
For each conversion request there should be either the line
No conversion is possible.
if insufficient conversion facts have been given, or a line of the form
<v3> <u1> = <v4> <u2>
all elements are as in the conversion request, except that the .?. has been replaced by a
decimal number <v4>, and is calculated, using only the given conversion facts previously
given, so that the left and right-hand side quantities are equal. There should be a single space
between all elements in the line. The numbers <v3> and <v4> must be formatted as follows:
<v4> is greater than or equal to 1,000,000 or less than 0.1, it must be printed in scientific
notation: a number between 1.000000 and 9.999999 printed with exactly six digits after the
decimal point, followed by .e+nn. or .e-nn., where .e. represents .times ten to the power
of., and .nn. is a two digit number.
, <v4> must be printed in standard decimal notation, with a decimal point
followed by exactly six digits.
both cases, the number printed must be the closest such number to the true answer, i.e.
round, don.t truncate.
Sample Input:
7200.0 second = 2 hour
10.0 glob = 1 decaglob
1 day = 24.0 hour
1 minute = 60 second
1 glob = 10 centiglob
1 day = 24 hour
1 year = 365.25 day
50 centiglob = ? decaglob
5.6 second = ? hour
3 millisecond = ? hour
5.6 second = ? day
1 day = ? glob
1 hour = ? second
1 year = ? second
Sample Output (corresponding to sample input)
50.000000 centiglob = 0.500000 decaglob
5.600000 second = 1.555556e-03 hour
No conversion is possible.
5.600000 second = 6.481481e-05 day
No conversion is possible.
1.000000 hour = 3600.000000 second
1.000000 year = 3.155760e+07 second
--
With best regards,
Gregory Edigarov
Jun 14 '06 #1
4 1673
Gregory Edigaroff wrote:
Hello, Everybody!

Ok, I urgently need the solution for a following task in C++. This is the task from programmers contest,
so I believe somebody have a solution for it.
I need either a full source code or a simple description of algorithm to solve this task.

[snip]

As per FAQs 5.2 and 5.3, "Do it yourself. If you get stuck, ask a
specific question."

Cheers! --M

Jun 14 '06 #2
Gregory Edigaroff wrote:
Ok, I urgently need the solution for a following task in C++. This is
the task from programmers contest, so I believe somebody have a
solution for it.
I need [..]


I think all those solutions are discussed in the FAQ 5.2.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jun 14 '06 #3
"Gregory Edigaroff" writes:
Ok, I urgently need the solution for a following task in C++. This is the
task from programmers contest,
so I believe somebody have a solution for it.
I need either a full source code or a simple description of algorithm to
solve this task.

thank a lot in advance.

Unit Conversion
A (measurement) unit is here represented by a single word containing only
lower-case letters. All
units are written as singular both in input and in output. A conversion
fact relates the size of two
units.
You are to convert a quantity in one unit to the equivalent quantity in a
different unit using only
a given set of conversion facts. These conversion facts are self
consistent; there is never more
than one conversion chain from any unit to any other unit.


<snip>
That doesn't sound like much of a contest to me. Where is the challenge?

global definiton:

struct Factoid
{
string name1;
string name2;
double k1;
double k2;
};

In main:
Factoid fa[100]; // factoid array

Not compiled.
If the operator is simply '=', add the data to the array. If it has a '?',
use the array to answer the question. Note that = works both ways, left to
right and right to left.
Jun 14 '06 #4
Gregory Edigaroff posted:

thank a lot in advance.


#include <finances.hpp>
#include <professional_services\homework_completion.hpp>

int main()
{
Finances::SumOfMoney amount( 100, US_DOLLAR );

ProfessionalServices::Consultation cons(HOMEWORK);

if ( cons.ProposeFee( amount ).Accepted() )
{
cons.Proceed( CallbackFuncWhenCompleted );
}
}

--

Frederick Gotham
Jun 14 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1190
by: Parvez | last post by:
I wanna build an application that performs certian tasks 1)User Loggin through the Active directory Authentication according to the user type i need to perform the following tasks 2)I need all...
2
1670
by: sunil | last post by:
Hi, We have lot of c and fortran archive libraries that have complex dependencies. We have different server tasks that use some of these libraries. We have developed a tool inhouse that links...
3
1461
by: johnb41 | last post by:
I am building a .net app that does some simple image tasks (Tiff files): viewing Tiff, viewing thumbnails from multipage tiff, rotation, page (frame) deletion, etc. The problem is that it is so...
15
4562
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
3
2632
by: Dean Craig | last post by:
I'm working with the new ASP.NET AJAX Control Toolkit. I have a map that has several key areas (hot spots) where when the user hovers over them, I want to pop up a small window with information in...
1
2311
by: karizmatrix22 | last post by:
Hi, I need a programmer who can write 3 programs for following questions below.Programs need to be ready before nextweek.thank you. Person who help me these 3 questions will be get paid.. I am...
6
2893
by: martin DH | last post by:
**Urgent Need** I'll throw out the basics and any assistance is very, very, very much appreciated! Access 2003 on XP On a form (frmMain) is an option group of check boxes (ReportFrame) from...
2
1165
by: cj | last post by:
My code below gives me "SQL: Column 'BTN' is not found." It will work if I use an inner join or just join but those two joins don't return all the rows. BTN has 5 rows, but arcust01 has only has...
5
2467
by: =?Utf-8?B?c2lwcHl1Y29ubg==?= | last post by:
Hi I have a Container that is an an Array List of Class Each ArrayList element can be the class or a another ArrayList of Class So there the ArrayList could look like Element 1 - Class...
0
7118
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7157
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,...
1
6862
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5452
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4886
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3087
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
637
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
282
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.