Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
matjul
/
iax0583
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
7df881f0
authored
Nov 15, 2018
by
matjul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
8fe9e989
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
0 deletions
hometask2.c
hometask2.c
0 → 100644
View file @
7df881f0
/**
* Author: Maksim Tjulenev
* Created: 12.11.2018
* Modified: 15.11.2018
* Description: This code is displaying the results of sharpshooter competition, finding the total sum of each shooter
* and finding best shooter and his place in the scoreboard
*/
#include <stdio.h> //including all the neccesary libralies
#include <stdlib.h>
void
fillingTheMatrixAndFindingSum
(
int
list
[
15
][
15
],
int
sum
[
15
]);
//naming function prototypes before the main function
void
findingTheHighestSumAndLocation
(
int
sum
[
15
]);
int
main
(){
int
list
[
15
][
15
];
//variable for holding matrix values
int
sum
[
15
]
=
{
0
};
//variable for holding row sums
int
i
;
printf
(
"Scoreboard
\n
"
);
//displaying some parts of the scoreboard
printf
(
"
\t
"
);
for
(
i
=
0
;
i
<
15
;
i
++
){
printf
(
"S%2.2d "
,
i
+
1
);
}
printf
(
"Sum
\n
"
);
fillingTheMatrixAndFindingSum
(
list
,
sum
);
//calling for the functions
findingTheHighestSumAndLocation
(
sum
);
return
0
;
}
void
fillingTheMatrixAndFindingSum
(
int
list
[
15
][
15
],
int
sum
[
15
]){
//function for filling the matrix with values and finding the sums
int
i
,
j
;
for
(
i
=
0
;
i
<
15
;
i
++
){
printf
(
"SHOOTER%2.2d: "
,
i
+
1
);
for
(
j
=
0
;
j
<
15
;
j
++
){
list
[
i
][
j
]
=
rand
()
%
101
;
printf
(
"%3d "
,
list
[
i
][
j
]);
sum
[
i
]
+=
list
[
i
][
j
];
}
printf
(
"%3d
\n
"
,
sum
[
i
]);
}
}
void
findingTheHighestSumAndLocation
(
int
sum
[
15
]){
//funtion for finding the highest sum and the shooter's location
int
i
,
highestSum
,
location
;
highestSum
=
sum
[
0
];
for
(
i
=
1
;
i
<
15
;
i
++
){
if
(
highestSum
<
sum
[
i
]){
highestSum
=
sum
[
i
];
location
=
i
+
1
;
}
}
printf
(
"
\n
Most accurate is SHOOTER%2.2d with %d points"
,
location
,
highestSum
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment