首页
编程语言
数据库
网络开发
Algorithm算法
移动开发
系统相关
金融统计
人工智能
其他
首页
>
> 详细
讲解CS139编程设计、辅导c/c++编程、讲解data留学生编程 辅导Database|辅导R语言编程
CS139 C Programming Project
November 24, 2020
The 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.
Pokémon Database
Part 1 - Structure (4 points)
Implement a structure named pokemon, which contains the following elements
1. 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]; or
struct 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 the
database is exceeded.
2. int delete_id(int id);
Delete the pokemon of given id from the database. Return 0 if successful. Return 1 if the
pokemon of given id doesn’t 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 height
1
(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 b
int descending (int a, int b) { return b>a; }
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 and
add 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 pokemon
Eevee, the function could find its evolution Vaporeon, etc.
Input and Output
The main function firstly reads the information of several pokemons, then reads a set of instructions
and 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. Remark
that each pokemon may have at least 1 type and at most 2 types. Types are separated with a single
comma.
Then there’s 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 the
enumeration 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.
There’s a sample of input and output in the appendix. Each instruction and its output is aligned. It
could be used to validate the functions.
Remark that the format of the output is not important. Do not bother with order of print (except
for sort_id or sort_id_plus), or number of blanks.
Charmander Charizard Pikachu Nidoran Lapras
Lapras
Pikachu Nidoran
Deleted successfully !
Pokemon of id 29 doesn’t exist in the database.
Charmander Charizard Pikachu Lapras
Lapras Pikachu Charizard Charmander
Charizard Charmander
Lapras
3
联系我们
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-21:00
微信:codinghelp
热点文章
更多
辅导 cs1b spring 2024 tth hw...
2024-04-19
讲解 managing financial risk...
2024-04-19
辅导 cs 0449 – project 5: /...
2024-04-19
辅导 elec 2141 digital circu...
2024-04-19
讲解 csc171 — videogame pro...
2024-04-19
讲解 comp3411 artificial int...
2024-04-19
讲解 stat3061: random proces...
2024-04-19
辅导 accounting 452, spring ...
2024-04-19
辅导 finc5001 foundations in...
2024-04-19
辅导 7ssmm712 – topics in a...
2024-04-19
讲解 com 337 - film studies ...
2024-04-19
辅导 mes202tc - digital vlsi...
2024-04-19
辅导 geography 2041b distanc...
2024-04-19
辅导 ecos3006 international ...
2024-04-19
讲解 fit5225 2024 sm1 creati...
2024-04-19
讲解 cit 593: introduction t...
2024-04-19
讲解 math 4931: take home ex...
2024-04-19
辅导 csci 547|info 533: syst...
2024-04-19
辅导 cs536-s24 intro to pls ...
2024-04-19
讲解 fit5212 - assignment 1辅...
2024-04-19
热点标签
cs 161
swen20003
comp282
csc1002
comp27112
comm1190
elec9764
acfi3308
acct7101
fin6035
comp2048
geog0163
comp2013
coen 146
dts101tc
comp4880/8880
cs 455
07
comp10002
comp30023
sehh2042
stat0045.
fil-30023
celen085
psyc40005
math40082
are271
comp9311
ee5311
imse2113
comp 2322
acct2102
fnd109
int102
is3s664
is6153
data4000
accfin5034
fit5212
cs536-s24
fit5225
ecos3006
mes202tc
finc5001
stat3061
csc171
cs1b
7ssmm712
bu.450.760
comp3411
cs170
swen90004
cpt206
comp5313/comp4313—large
bl5611
kxo206
comp532
elec207
kxo151
cs 2820
cpt108
math2319
dts204tc
qm222
comp2511
ccs599
infs1001
mat2355
eeee4123
25721
ifn647
pols0010
hpm 573
comp9417
stat0023
csci 1100
qbus6860
comp2003j
cse340
cs 2550
cs 61b
cs360
fin 3080
ierg 4080
cs6238
cit 594
finm7406
hw6
elec9713
asb-2522
mso3610
lit301
mcd4540
geog0030
125.330
biol0006
125.320
cs3334
fit2093
acct1101
110.309
masy1-gc
cs314
elec0048
gds104
mg5637
fit2096
math5905
eel4837
sehs4515
cpt s 321
asb2522 investment
ma214
co2104
mgmt2015
32516
math32051
econ1012
mark2052
comp3310
econ0019
dsci 525
abmf3184
aps106
antc27
finm7401
itp122
tech2300
math3026
comp9024
cao107
36318
is2022
cs 211
fit1047
ics4u
2xc3
en.540.635
4qqmn506
finn3081
phys10362
sta601
ec481e
math5165
csi 2120
el1205
comp7250
ecos3013
beam065
info1113
comp2051
csc325
mne 6130
ai6126
ecs150
is61x6
cse115
seng6110
bus265
cpts260
mphy0009
csc306
eco2011
ee3004
inu1111
st332
idepg001
info6001
cpt106
finm7409
fit3152
fins5516
qbus2820
isom3028
eece 6083
ceg5304
mcd4700
eecs 493
eg25h4
38173
elc5216
infs6071
lubs5996m
7ssmm803
glbh0031
phys1120
comp52715
eeb240
math3836
cmns3490
iy5610/4610
cpt304
ac6105
psyc3241
fin570
218.323
lng310
rim3352
bio206
comp3334
联系我们
- QQ: 99515681 微信:codinghelp
© 2024
www.7daixie.com
站长地图
程序辅导网!