” 写作CS139编程设计、 辅导c/c++编程CS139 C Programming ProjectNovember 24, 2020The objective of this project is to practice the implementation of structures and functions in C.The submission of the project requires the source code and a readme.pdf describing it.Pokmon DatabasePart 1 – Structure (4 points)Implement a structure named pokemon, which contains the following elements1. id (int)2. name (char*)3. height (float)4. type (char*)It is suggested to Use an array of the designed structure as the database, for example:struct pokemon pkdb[100]; orstruct pokemon *pkdb[100];However, other forms such as linked list are also acceptable.Part 2 – Basic Functions (4 points)The following functions should be realized.1. int insert(int id, char *name, float height, char *type);Add a new pokemon into the database. Return 0 if successful. Return 1 if the max size of thedatabase is exceeded.2. int delete_id(int id);Delete the pokemon of given id from the database. Return 0 if successful. Return 1 if thepokemon of given id doesnt exist in the database.Then print a sentence to describe the situation according to the return value.Part 3 – Extended Functions (8 points)The following Functions should be realized.3. void find_height(int param);param {1, 2}. Find the pokemons with maximum height (param=1) or minimum height1(param=2). Print the name of the found pokemons.Make sure to print all the pokemons if they have the same maximum or minimum height.4. void sort_id(); Sort the database with id-ascending order. Print all pokemon names in order.5. void sort_id_plus(int param);param {1, 2}. Sort the database with id-ascending order (param=1) or id-descending order(param=2). Print all pokemon names in order.Use pointer to function (such as the functions below) instead of duplicating the sort process.int ascending (int a, int b) { return ba; }int descending (int a, int b) { return ba; }6. void group(char* type);Print the name of all the pokemons belonging to the given type.Part 4 – Free Design (4 points)Design and implement a feature for the database. Feel free to add any element in the structure andadd any function. Explain this feature in detail in readme file.For example, it could be a great idea to implement the evolutionary chains of pokemons. For pokemonEevee, the function could find its evolution Vaporeon, etc.Input and OutputThe main function firstly reads the information of several pokemons, then reads a set of instructionsand prints Corresponding output.The first line of input is an integer n 50, indicating the number of pokemons in the following lines.For each pokemon, there are 4 lines containing its id, name, height and type respectively. Remarkthat each pokemon may have at least 1 type and at most 2 types. Types are separated with a singlecomma.Then theres an integer m 20, indicating the number of instructions. Each line contains 1 instruction,which is consisted of a number and a parameter, separated by a blank. The number is theenumeration of Corresponding function: 2 delete_id, 3 find_height, 4 sort_id, 5 sort_id_plus, 6 group.The parameter is passed into the function as argument.Theres a sample of input and output in the appendix. Each instruction and its output is aligned. Itcould be used to validate the functions.Remark that the format of the output is not important. Do not bother with order of print (exceptfor sort_id or sort_id_plus), or number of blanks.Charmander Charizard Pikachu Nidoran LaprasLaprasPikachu NidoranDeleted Successfully !Pokemon of id 29 doesnt exist in the database.Charmander Charizard Pikachu LaprasLapras Pikachu Charizard CharmanderCharizard CharmanderLapras如有需要,请加QQ:99515681 或WX:codehelp
“
添加老师微信回复‘’官网 辅导‘’获取专业老师帮助,或点击联系老师1对1在线指导。