首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
讲解数据库SQL|讲解留学生Prolog|解析R语言编程|调试Matlab程序
项目预算:
开发周期:
发布时间:
要求地区:
CSCI 151: Programming for Scientists and Engineers
Programming Assignment II
Deadline: 17 March 2021, 8:00pm
Explanation for Task1 and Task 2:
You will write programs to handle the games between the wrestlers and maintain their
scores in these tasks. First, create the following struct:
typedef struct{
int id;
char firstName[100];
char lastName[100];
int birthYear;
int score;
} wrestler;
A wrestler is identified by the following features: id (int), first name (char array/string),
last name (char array/string), birth year (int), and score (int).
Task 1 (25 points): Copy&paste the following lines to the beginning of your main
function. Your task is to make your code work and complete it according to the
descriptions given below. (Your main will contain the following lines exactly).
char inputFile[100];
//creates a char array (string)
strcpy(inputFile,"in.txt");
//copies “in.txt” into the string, inputFile
int n = getNumberOfWrestlers(inputFile);
/*retrieves the number of wrestlers in inputFile and assigns it
to variable n*/
wrestler list[n];
/*creates a wrestler array, list, of size n to store wrestlers‘
info*/
init(list, inputFile);
/*initializes list, which is defined above, with the information
in inputFile. You need to create a function named init that
takes 2 parameters suitable to its usage here*/
printScoreBoard(list, n);
/*prints the scoreboard to screen. You need to create a
function named printScoreBoard that takes 2 parameters suitable
to its usage here*/
writeTheChampion(list, n);
/*prints the champion with the maximum score to screen. You
need to create a function named writeTheChampion that takes 2
parameters suitable to its usage here*/
The format of the file “in.txt” is shown below:
Number_of_wrestlers(N)
id1 firstname1 lastname1 birthyear1 score1
id2 firstname2 lastname2 birthyear2 score2
…
idN firstnameN lastnameN birthyearN scoreN
For example, “in.txt” may contain the following lines:
4
118 john brown 2000 100
234 tomas jhonson 2001 150
56 kevin whale 2000 50
7909 michael daisy 1998 200
This means that there are 4 wrestlers in this game. The first wrestler (john brown) with id
118 was born in 2000 and has a score of 100. The second wrestler (tomas jhonson) with
id 234 was born in 2001 and has a score of 150, etc. Then, the above code fragment
initializes the wrestler list array with all this information and prints out the following
output, where the first 5 lines are generated by printScoreBoard and the last 2 by
writeTheChampion.
Printing the score board
118 john brown 2000 100
234 tomas jhonson 2001 150
56 kevin whale 2000 50
7909 michael daisy 1998 200
The champion is
7909 michael daisy 1998 200
Task 2 (25 points): Add the following lines to the end of your main. Your task is to make
your code work and complete it according to the descriptions given below. (Your main
will contain the lines given in Task 1 followed by the following lines exactly).
strcpy(inputFile,"games.txt");
//copies “games.txt” into the string, inputFile
processGames(inputFile, list, n);
/*The matches between the wrestlers are examined as given in
inputFile and then the list of size n is updated accordingly.
You need to create a function named processGames that takes 3
parameters suitable to its usage here*/
printScoreBoard(list, n);
/*prints the scoreboard to screen. This function is the same as
the one created in Task 1*/
writeTheChampion(list, n);
/*prints the champion with the maximum score to screen. This
function is the same as the one created in Task 1*/
The format of the file “games.txt” is shown below:
wrestler_id1 wrestler_id2 match_result score
...
Explanation of the format: Each line consists of 4 integers. The first two numbers
indicate that there is a match between wrestlers with wrestler_id1 and
wrestler_id2. The third number (match_result) can be either 0, 1, or 2, indicating
who the winner is. If 1 then the first wrestler wins and his score is increased by score,
which is the fourth integer in the line. If 2 then the second wrestler wins and his score is
increased by score. If 0 then there is a tie in the game and both wrestlers’ scores are
increased by score. There is no limit to the number of matches presented in
“games.txt”. processGames function has to read the “games.txt” and update list array
accordingly.
For example, assume “game.txt” contains the following lines:
118 234 1 20
234 7909 2 40
7909 56 0 10
56 118 1 50
234 7909 0 15
Then according to the first match, the wrestler with id 118 wins the match against the
wrestler with id 234 and his score is increased by 20, making it 120. According to the
second match, the wrestler with id 7909 wins the match against the wrestler with id 234
and his score is increased by 40, making it 240, etc. At the end, the above code
fragment modifies the scores using this information and prints out the following output,
where the first 5 lines are generated by printScoreBoard and the last 2 by
writeTheChampion.
Printing the score board
118 john brown 2000 120
234 tomas jhonson 2001 165
56 kevin whale 2000 110
7909 michael daisy 1998 265
The champion is
7909 michael daisy 1998 265
Task 3 (25 points). In this assignment, you are asked to obtain a binary image
consisting of 0s and 1s given a grayscale image img.txt consisting of values from 0
to 255. The size of the provided input image img.txt is 64x96. Binarization is the
process of taking a grayscale image and converting it to black-and-white, essentially
reducing the information contained within the image from 256 gray levels to 2 levels:
black and white.
a. Import the provided image called img.txt using file I/O functions.
b. Use the following structure containing the image height, width and
an array imgdata to store the image data:
struct image{
int height;
int width;
int imgdata[64][96];
};
c. Binarize the input image three times by using three different
threshold values: T1 = 64, T2 = 128, T3 = 192. To do the binarization,
perform the following step. If the input image is 𝐼[𝑚, 𝑛], then the resulting
binary image is
d. Store the 3 resulting binary images as .txt files called binary1.txt,
binary2.txt, binary3.txt for three values of T, accordingly.
Example of an input image with size 3x3:
100 130 40
20 74 50
240 30 200
After using T1 = 64, the binary image will be
1 1 0
0 1 0
1 0 1
After using T2 = 128, the binary image will be
0 1 0
0 0 0
1 0 1
After using T3 = 192, the binary image will be
0 0 0
0 0 0
1 0 1
Task 4 (25 points). Write a program that will determine a hidden integer 3-tuple
geometric progression written in consecutive order. Geometric progression is an
ordered list of numbers in which each term after the first is found by multiplying
the previous one by a fixed non-zero number called the common ratio. The initial
array should contain more than 3 integer elements and the values should be
greater than 0. Output the geometric progressions and their common ratios. If no
geometric progressions are found, output “None”.
For example,
● If the input array is (1, 2, 4, 8, 7, 9) then the output should be the
following two geometric progressions: (1, 2, 4) with common ratio
equal to 2, and (2, 4, 8) with common ratio equal to 2.
● If the input array is (1, 4, 2, 8) then there are no geometric
progressions stored in consecutive order.
● If the input array is (5, 2, 25, 5, 1, 3), then there is one geometric
progression: (25, 5, 1) with a common ratio equal to 1/5.
● If the input is (1, 2, 4, 1, 3, 9), then there are two geometric
progressions: (1, 2, 4) with a common ratio equal to 2, and (1, 3, 9)
with a common ratio equal to 3.
Rules:
● Late submissions will NOT be accepted. In the case of late submission, a grade 0
is given.
● No deadline extensions will be given.
● You will lose 50 points if the program does not compile on the online compiler,
https://repl.it/languages/c.
● 5 points will be given for indentation and 5 for comments.
● Assignments must be done individually.
● Submitted codes will be automatically checked using tools that detect plagiarism.
● You may be asked to explain your code and rewrite a part of it in front of the
instructors.
● Please submit each task in a separate .c file naming as task1.c, task2.c etc. for
each task of the assignment and submit in a zip file to the submission box of
Moodle.
● All files must be with .c format. All other formats of files will not be accepted.
软件开发、广告设计客服
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
软件定制开发网!