Annulleret

2 programs (1 in C or C++ & 1 in SML/NJ or MLton or OCaml) [deadline 15/6/2014]

Elections Race

The recent experience from the local elections showed that the procedure consisting of one or maximum two rounds is really [url removed, login to view] the european council decided that setting up elections in the middle of the economical crisis is an unnecessary [url removed, login to view] local elections will be replaced by another "success event" which is going to attract many tourists and make some money for every region of the [url removed, login to view] by a recent speech of a candidate "we are a new political party and we performed a race to end up in that position" it has been decided that the new elections procedure will be based on a true race with many [url removed, login to view] rules are the following: The route where the race is taking place is a circle with length L. One point of the route is chosen to be the starting/ending point. Every candidate out of the N takes his place in some distance D from the start,counted [url removed, login to view] the candidates are numbered from 1 to N,again clockwise, starting from the one closer to the right of the starting point. When the race starts every candidate runs clockwise with his own speed. If a candidate reaches another candidate, that was placed in front of him in the beginning, then the one that was in front quits the [url removed, login to view] elections race finishes when it's not possible for any candidate to [url removed, login to view] the candidates that haven't quitted at that point can be considered as winners.

-->The exercise wants you to write 2 programs (one in C or C++ AND one in SML/NJ or MLton or OCaml) that take as input the parameters of the elections race and return as output the turn that the candidates quit the race(based on their numbers). The input will be read from a file as the following [url removed, login to view] first line has two positive integers N and L(N <= [url removed, login to view] and L < [url removed, login to view] ). The i-th from the next N lines will have the parameters of the i-th candidate : the intger number D(i) ,which is 0<=D(1) <D(2)<...<D(N) <L , and the speed V(i) which is a float number with 2 digits after the comma ( 0< V(i)<= 5 ). Distances are given in meters and speeds in meters/seconds.

Constraints: Time: 10seconds Memory: 256MB

Above there are some examples in both C and ML:

In C,C++,MLton,OCaml:

> ./agonas [url removed, login to view]

2 3 5 4 6

In SML/NJ:

- agonas "[url removed, login to view]";

val it = [2,3,5,4,6] : int list

where the input file is

> cat [url removed, login to view]

6 150

0 [url removed, login to view]

30 0.8

60 0.5

70 1

120 0.1

140 0.9

The winner of the elections race above is the first candidate, the one that begins from the starting/ending [url removed, login to view] that between different numbers in both input and output we have to leave a [url removed, login to view] program in SML/NJ must define a function with name agonas which will give us a list of integers as a return.

Færdigheder: Algoritme, C programmering, C++ Programmering

Se mere: space winners, sml programming, programming programs, positive integers examples, notice leave, ml programming, make money programming, list positive integers, lines circle, int v, float programming, exercise programming, event based programming, define programming, read example, programming input output, programming define, cplusplus programming examples, beginning programming, winner takes, val , winners, th write, ocaml, nj

Om arbejdsgiveren:
( 3 bedømmelser ) Athens, Greece

Projekt-ID: #6044526

2 freelancere byder i gennemsnit $33 for dette job

sunethsl

A proposal has not yet been provided

$35 USD på 1 dag
(0 bedømmelser)
0.0
hindmostone

Hello! The task is doable. it could be reduced to line intersection enumerator on the (x, t)-plane. So, I need to write 2 programs - one in C++ & one in OCaml. > return as output the turn that the candidates q Mere

$30 USD på 1 dag
(0 bedømmelser)
0.0