辅导CSC 3002编程、 写作c/c++程序

” 辅导CSC 3002编程、 写作c/c++程序CSC 3002 (Spring 2021) Assignment 1Problem 1Exercise 2.9:The combinations function C(n, k) described in this chapter determines the number of waysyou can choose k values from a set of n elements, ignoring the order of the elements. If the order ofthe value matters-so that, in the case of the coin example, choosing a quarter first and then a dimeis 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 thefollowing mathematical formulation:P(n, k) = n!(n k)!Although this definition is mathematically correct, it is not well suited to implementation in practicebecause the factorials involved can get much too large to store in an integer variable, even when theanswer is small. For example, if you tried to use this formula to calculate the number of ways toselect two cards from a standard 52 -card deck, you would end up trying to evaluate the followingfraction:80, 658, 175, 170, 943, 878, 571, 660, 636, 856, 403, 766, 975, 289, 505, 440, 883, 277, 824, 000, 000, 000, 00030, 414, 093, 201, 713, 378, 043, 612, 608, 166, 064, 768, 844, 377, 641, 568, 960, 512, 000, 000, 000, 000even 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 thefact 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 asense 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 2Exercise 3.20:There is no gene for the human spirit. – Tagline for the 1997 film GATTACAThe genetic code for all living organisms is carried in its DNA-a molecule with the remarkablecapacity to replicate its own structure. The DNA molecule itself consists of a long strand of chemicalbases wound together With a similar strand in a double helix. DNAs ability to replicate comesfrom the fact that its four constituent bases-adenosine, cytosine, guanine, and thymine-combinewith 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 attachthemselves. As an example, suppose that you have the following DNA strand, in which the positionof 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 tothe longer one. If, for example, you were trying to find a match for the strandthe rules for DNA dictate that this strand can bind to the longer one only at position 1:By contrast, the strandmatches at either position 2 or position 7.Write a functionint 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 inthe find method for the string class, the optional start parameter indicates the index position atwhich 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 3Exercise 4.8:Even though comments are essential for human readers, the compiler simply ignores them. Ifyou are writing a compiler, you therefore need to be able to recognize and eliminate comments thatoccur in a source file.Write a functionvoid removeComments (istream is, ostream os)that copies characters from the input stream is to the output stream os, except for charactersthat appear inside C + + comments. Your implementation should recognize both commentconventions: 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 containedinside quoted strings, but you should feel free to ignore that detail. The problem is tricky enoughas it stands.Requirments Hints:Please fill in the TODO part of RemoveComments.cpp. You can prepare your test file underthe res folder in Stanford Library for testing. The generated results should print in the Stanfordconsole.Problem 4Exercise 4.9:Books were bks and Robin Hood was Rbinhd. Little Goody Two Shoes lost her Os and so didGoldilocks, and the Former became a whisper, and the latter sounded like a key jiggled in a lck. Itwas impossible to read cockadoodledoo aloud, and parents gave up reading to their children, andsome gave up reading altogether…. – James Thurber, The Wonderful O, 1957In James Thurbers childrens story The Wonderful O, the island of Ooroo is invaded by pirateswho set out to banish the letter O from the alphabet. Such censorship would be much easier withmodern technology. Write a program that asks the user for an input file, an output file, and astring 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 theyappear in uppercase or lowercase form.As an example, suppose that you have a file containing the first few lines of Thurbers novel, asfollows:If you run your program with the inputit 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 beRequirments 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 generatednew file will existed in the build content named as build-Assignment1-. . . .Requirements for AssignmentIve provided a project named as Assignment1.pro. You should write TODO part in each cppfile according to the Problem requirements. The resources and test files are provided under resfolder such as P3RemoveComments.cpp and TheWonderfulO.txt. You can use them with relativepath directly after you compile the whole project. Finally, please pack your whole project files intoa single .zip file, name it using your student ID (e.g. if your student ID is 123456, hereby the fileshould 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, toensure that the codes are indeed written by yourself. Please also note that we may check whetheryour 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, youwill obtain late penalty in the assignment marks. If you submit more than 3 days later than thedeadline, 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 requirementsof 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 theirprograms can be compiled.Reminder: For Windows users, please switch you input language to English before interactingin Stanford console. Or, you will get no response.如有需要,请加QQ:99515681 或WX:codehelp

添加老师微信回复‘’官网 辅导‘’获取专业老师帮助,或点击联系老师1对1在线指导