
November 19th, 2012, 09:47 AM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 1
Time spent in forums: 44 m 56 sec
Reputation Power: 0
|
|
|
Please i need help
Hi Every Body.
I want your help to program this problem if you don't mind
and thank you
==========================================
Scenario:
You are to help an electrician (shown in the picture below) to estimate the number of steps that he has to climb in order to replace a bulb hanged at height H from the ground level.
In each case, there are B number of bulbs to be replaced by the electrician; each of which is hanged in the ceiling at different height Hi. Each time (case) the electrician uses a ladder of L meters in height and it is containing S number of steps that are distributed at equal distance from each. The number of step S includes the FIRST and the LAST step which are located at the bottom and top edge of the ladder.
To test your program, the length of the ladder (L) and the number of its steps (S), and the number of bulbs to be replaced (B) and their heights (Hi) from the ground level are given in a text file which contains M number of test cases given in the top of the input file. Then, for each test case the input file contains TWO lines: the first line contains length of the ladder (in meters), the number of steps in the ladder (maximum 99) and the number of bulbs (maximum 6) to be replaced. The second line contains the height (in centimeters) of each bulb from the ground level (see the sample input file)
Write a C++ program to read the input (which is described above) from a text file (say ladder.txt) and then counts the number of steps that the electrician must climb to replace each bulb in each case. If a bulb cannot be reached by the electrician then your program should display ‘N’ (to indicated Not-Possible). The program must also display the total number of bulbs replaced, the total number of bulbs not replaced, and the total number of steps that are climbed by the electrician in order to replace all reachable bulbs.
1. Assumption#1: The ladder is used vertically where the electrician must stand on the step that immediately passes the bottom of the bulb. So the program must count the steps up to that step.
2. Assumption#2: Your calculation should ignore the height of the electrician himself
3. Hint: A bulb is not reachable if the length of the ladder is less than the height of the bulb
sample of input file
num(25) is the num of cases
25
1.11 11 4
256 168 347 497
1.44 12 4
555 211 210 118
3.93 6 2
216 383
1.98 12 6
154 376 599 303 453 358
1.52 14 5
487 447 227 248 120
3.62 14 1
106
4.35 8 5
241 578 558 243 387
3.04 13 5
218 86 97 377 445
2.43 7 5
268 45 423 301 307
3.77 6 5
161 158 251 561 113
2.08 12 2
448 596
4.81 9 6
173 264 127 533 61 331
3.8 11 2
444 310
2.82 12 6
31 53 464 446 135 425
1.3 5 5
592 473 109 6 321
2.36 6 2
73 499
3.65 8 4
161 591 275 437
1.32 11 4
32 465 586 85
3.53 5 2
82 449
4.59 13 4
472 361 273 262
3.27 6 5
237 380 202 93 497
3.14 5 5
525 153 479 318 496
1.62 10 6
94 470 294 391 302 224
2.36 13 6
521 304 244 496 393 242
1.47 12 3
80 562 271
Last edited by MoH99 : November 19th, 2012 at 10:12 AM.
Reason: good title
|