首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
辅导CSC 3002编程、讲解c/c++程序、辅导program设计编程 辅导Python程序|辅导Python编程
项目预算:
开发周期:
发布时间:
要求地区:
CSC 3002 (Spring 2021) Assignment 1
Problem 1
Exercise 2.9:
The combinations function C(n, k) described in this chapter determines the number of ways
you can choose k values from a set of n elements, ignoring the order of the elements. If the order of
the value matters-so that, in the case of the coin example, choosing a quarter first and then a dime
is seen as distinct from choosing a dime and then a quarter-you need to use a different function,
which computes the number of permutations. This function is denoted as P(n, k), and has the
following mathematical formulation:
P(n, k) = n!
(n − k)!
Although this definition is mathematically correct, it is not well suited to implementation in practice
because the factorials involved can get much too large to store in an integer variable, even when the
answer is small. For example, if you tried to use this formula to calculate the number of ways to
select two cards from a standard 52 -card deck, you would end up trying to evaluate the following
fraction:
80, 658, 175, 170, 943, 878, 571, 660, 636, 856, 403, 766, 975, 289, 505, 440, 883, 277, 824, 000, 000, 000, 000
30, 414, 093, 201, 713, 378, 043, 612, 608, 166, 064, 768, 844, 377, 641, 568, 960, 512, 000, 000, 000, 000
even though the answer is the much more manageable 2652(52 × 51).
Write a function permutations (n, k) that computes the P(n, k) function without calling the
fact function. Part of your job in this problem is to figure out how to compute this value efficiently.
To do so, you will probably find it useful to play around with some relatively small values to get a
sense of how the factorials in the numerator and denominator of the formula behave.
Requirments & Hints:
Please fill in the TODO part of Permutations.cpp.
Problem 2
Exercise 3.20:
There is no gene for the human spirit. - Tagline for the 1997 film GATTACA
The genetic code for all living organisms is carried in its DNA-a molecule with the remarkable
capacity to replicate its own structure. The DNA molecule itself consists of a long strand of chemical
bases wound together with a similar strand in a double helix. DNA’s ability to replicate comes
from the fact that its four constituent bases-adenosine, cytosine, guanine, and thymine-combine
with each other only in the following ways:
• Cytosine on one strand links only with guanine on the other, and vice versa
• Adenosine links only with thymine, and vice versa.
Biologists abbreviate the names of the bases by writing only the initial letter: A, C, G, or T.
Inside the cell, a DNA strand acts as a template to which other DNA strands can attach
themselves. As an example, suppose that you have the following DNA strand, in which the position
of each base has been numbered as it would be in a C + + string:
Your mission in this exercise is to determine where a shorter DNA strand can attach itself to
the longer one. If, for example, you were trying to find a match for the strand
the rules for DNA dictate that this strand can bind to the longer one only at position 1:
By contrast, the strand
matches at either position 2 or position 7.
Write a function
int findDNAMatch (string s1, string s2, int start = 0 ) ;
that returns the first position at which the DNA strand s1 can attach to the strand s2. As in
the find method for the string class, the optional start parameter indicates the index position at
which the search should start. If there is no match, findDNAMatch should return -1.
Requirments & Hints:
Please fill in the TODO part of FindDNAMatch.cpp.
Problem 3
Exercise 4.8:
Even though comments are essential for human readers, the compiler simply ignores them. If
you are writing a compiler, you therefore need to be able to recognize and eliminate comments that
occur in a source file.
Write a function
void removeComments (istream & is, ostream & os)
that copies characters from the input stream is to the output stream os, except for characters
that appear inside C + + comments. Your implementation should recognize both comment
conventions:
• Any text beginning with /? and ending with ?/, possibly many lines later.
• Any text beginning with // and extending through the end of the line.
The real C + + compiler needs to check to make sure that these characters are not contained
inside quoted strings, but you should feel free to ignore that detail. The problem is tricky enough
as it stands.
Requirments & Hints:
Please fill in the TODO part of RemoveComments.cpp. You can prepare your test file under
the res folder in Stanford Library for testing. The generated results should print in the Stanford
console.
Problem 4
Exercise 4.9:
Books were bks and Robin Hood was Rbinhd. Little Goody Two Shoes lost her Os and so did
Goldilocks, and the former became a whisper, and the latter sounded like a key jiggled in a lck. It
was impossible to read ”cockadoodledoo” aloud, and parents gave up reading to their children, and
some gave up reading altogether.... - James Thurber, The Wonderful O, 1957
In James Thurber’s children’s story The Wonderful O, the island of Ooroo is invaded by pirates
who set out to banish the letter O from the alphabet. Such censorship would be much easier with
modern technology. Write a program that asks the user for an input file, an output file, and a
string of letters to be eliminated. The program should then copy the input file to the output file,
deleting any of the letters that appear in the string of censored letters, no matter whether they
appear in uppercase or lowercase form.
As an example, suppose that you have a file containing the first few lines of Thurber’s novel, as
follows:
If you run your program with the input
it should write the following file:
If you try to get greedy and banish all the vowels by entering aeiou in response to the prompt,
the contents of the output file would be
Requirments & Hints:
Please fill in the TODO part of BanishLetters.cpp. The test file is named as TheWonderfulO.txt.
The prepared test file is provided under the res folder in Stanford Library for testing. The generated
new file will existed in the build content named as build-Assignment1-. . . .
Requirements for Assignment
I’ve provided a project named as Assignment1.pro. You should write TODO part in each cpp
file according to the problem requirements. The resources and test files are provided under res
folder such as P3RemoveComments.cpp and TheWonderfulO.txt. You can use them with relative
path directly after you compile the whole project. Finally, please pack your whole project files into
a single .zip file, name it using your student ID (e.g. if your student ID is 123456, hereby the file
should be named as 123456. zip ), and then submit the .zip file via BB system.
Please note that, the teaching assistant may ask you to explain the meaning of your program, to
ensure that the codes are indeed written by yourself. Please also note that we may check whether
your program is too similar to your fellow students’ code using BB.
Please refer to the BB system for the assignment deadline. For each day of late submission, you
will obtain late penalty in the assignment marks. If you submit more than 3 days later than the
deadline, you will receive 0 in this assignment.
Marking scheme:
• 25% Marks will be given to students who have submitted the program on time.
• 25% Marks will be given to students who wrote the program that meet all the requirements
of the questions
• 25% Marks will be given to students who programs that can be compiled without errors.
• 25% Marks will be given to students whose programs produce the correct output if their
programs can be compiled.
Reminder: For windows users, please switch you input language to English before interacting
in Stanford console. Or, you will get no response.
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代做ceng0013 design of a pro...
2024-11-13
代做mech4880 refrigeration a...
2024-11-13
代做mcd1350: media studies a...
2024-11-13
代写fint b338f (autumn 2024)...
2024-11-13
代做engd3000 design of tunab...
2024-11-13
代做n1611 financial economet...
2024-11-13
代做econ 2331: economic and ...
2024-11-13
代做cs770/870 assignment 8代...
2024-11-13
代写amath 481/581 autumn qua...
2024-11-13
代做ccc8013 the process of s...
2024-11-13
代写csit040 – modern comput...
2024-11-13
代写econ 2070: introduc2on t...
2024-11-13
代写cct260, project 2 person...
2024-11-13
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!