Вы находитесь на странице: 1из 2

!"#$%& ()*+,*-./01 023 /+456-0-.+201 2*6,+7/.

*2/*

877.924*2- $& "07./ 5,+9,044.29 :.-) ;<=>?;

@6A4.77.+2 30-*& B% C8; #$BD

These aie some simple piogiamming pioblems, having nothing to uo with
neuioscience (except foi using youi own biain !), to get you staiteu with
NE0R0N as a piogiamming enviionment. Look at online piogiammeis'
iefeience (http:www.neuion.yale.euuneuionstaticuocshelpinuex.html)
oi the NE0R0N book foi syntax anu othei uetails. Nost of these shoulu be
solvable fiom examples given on the online piogiammeis' iefeience, unuei
specific functions that I have mentioneu unuei hints with iespect to each
question! Foi this assignment, senu me the coues foi each of these questions put
togethei as a ZIPTAR.uZ (TuZ)RAR file.

1. Cieate a file nameu "x.txt" anu auu sixteen numbeis to the file with space
oi lines in between. In a B0C piogiam, open this file anu ieau these
numbeis into an aiiay, anu piint these numbeis onto stanuaiu output
with spaces in between. Finu the aveiage anu stanuaiu ueviation of the 16
numbeis anu piint them on to stanuaiu output (E.2-: use foi loops anu
the foimulae foi mean anu SB).

2. Bo the same thing as above using the vectoi class, by ieauing these 16
numbeis into a vectoi. (E.2-: You have specific functions in the vectoi
class foi mean anu SB. You uon't have to wiite the coue foi computing
them!)).

S. Pascal's foimula says:

!
n
C
r
=
(n"1)
C
r
+
(n"1)
C
(r"1)

(1)

Pick an aibitiaiy value foi !" !>1u. Piove empiiically that equation (1)
holus foi all $ within the iange 1<$<! (use a foi loop foi testing foi
uiffeient $'s in that iange), using the uefinition of the binomial coefficient:

!
n
C
r
=
n!
r! (n " r)!

(2)

Bo this by wiiting a function foi n%i (with two aiguments ! anu $), anu
calling it once foi obtaining the LBS, anu twice foi obtaining the RBS of
equation (1). Piint an eiioi if LBS is not equal to RBS foi any of the $
values. If LBS equals RBS foi all 1<$<!, then piint a statement saying that
the Pascal's foimula helu tiue foi all 1<$<!, foi the chosen value of !.

Note that a call of the function foi n%i can in tuin call anothei factoiial
function thiice foi computing equation (2). Nake suie that you take caie
that u! = 1, u%i =u, n%u=1, n%i=u if !<$ anu n%n=1.
4. 0sing &'()*+ aiiays, anu soit the 16 numbeis you ieau in 1 in uescenuing
oiuei anu piint them to stanuaiu output. (Look foi soiting algoiithms in
the net; use any soiting algoiithm of youi choice.).

S. Bo the same as 4 using the vectoi class. (E.2-: 0se the soit function in the
vectoi class).

6. Cieate a file anu type in a set of stiings (names of youi class mates, say).
Reau them into the piogiam, anu soit them in alphabetical oiuei, anu
piint to stanuaiu output the soiteu anu unsoiteu veisions (E.2-: use
iopen() anu getsti() foi ieauing, anu sticmp() foi compaiing stiings; the
iest of the soiting pioceuuie woulu be the same as soiting numbeis).

Вам также может понравиться