Star system names will be no larger than 30 characters. Star system names may contain alpha-numeric characters, whitespace, and punctuation. Next will be the name of the destination star system (which is always different than the current star system) on a line of its own, followed by the x, y, and z coordinates of that star system, all on the same line, all separated by a single space. An entry will consist of the name of the current star system on a line of its own, followed by the x, y, and z coordinates of that star system, all on the same line, all separated by a single space. The input file will begin with a line containing the integer n ( 0 < n < 200), representing the number of entries to process. Help save the Millennium Falcon and its crew so they can help the Rebel Alliance defeat the Empire! Your task is to aid Leia in calculating the distance between two star systems with accuracy of two digits to the right of the decimal. Han: Leia, I hope your math is accurate to two digits of precision to the right of the decimal point. Luke: No problem Han, R2 will provide the coordinates and Leia will do the math, let's get out of here! if you can get me the name and coordinates of the current star system, followed by the name and coordinates of the destination star system, followed by the distance in galactic units between the two, so I can enter it all in the Hyper-Computer and make the jump to hyperspace. Looks like you didn't pay much attention, Han. Leia (interrupting): They also teach manners and hygiene in school, but those are usually before grade 4. Han: Great, so everyone's a genius but me! I'll congratulate you all on your brilliance later. Luke: Hey, I remember that! It looks like this (he draws out the formula): The result is in galactic units, of course. Anyone that's been to school through the 10th galactic grade knows that the distance between two points, or star systems, in 3-space is the square root of the sum of the difference between the x-coordinates squared, the difference between the y-coordinates squared, and the difference between the z-coordinates squared. Han: Oh really, your worship? I suppose you're going to tell us they taught you that in `Princess School'. Leia: I beg your pardon, but it doesn't take a math tech to do those kinds of calculations. I'm not up on the tech math to do that and I don't see anyone else here that's a likely candidate. Han: Great, but since the Navi-Computer is down, we need not only the 3-space coordinates, but the distance between our current location and our destination. The Rebel Alliance is depending on us!Ĭ3PO: Your Highness, R2D2 says he has a star map of the galaxy with coordinates in 3-space for each location! Leia: There must be something we can do! We can't go out like this. Luke: I have a very bad feeling about this. R2D2: whistle, chirp, beep, beeeeeeeeeeeeeeeeeeep!Ĭhewbacca: Grooooooooooooooaaaaaaaaannnnn! Leia: He's right Luke, we need proper calculations entered or. Han: Travelin' through hyperspace ain't like dustin' crops, boy! Without precise calculations we could fly right through a star or bounce too close to a supernova, and that'd end your trip real quick, wouldn't it? Luke: Han, why not just jump to hyperspace? We can't hold up to that Imperial Cruiser much longer! The Falcon has taken minimal damage to the aft and port thrusters, but the Navi-Computer has been damaged preventing a jump to hyperspace and escape. An Imperial Cruiser and its cohort of Tie Fighters are hot on the tail of the Millennium Falcon.
0 Comments
Leave a Reply. |