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
cf602541
authored
6 years ago
by
matjul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
43cda1ed
master
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
91 additions
and
0 deletions
hometask2fixed.c
hometask2fixed.c
0 → 100644
View file @
cf602541
/**
* 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
fillingTheMatrix
(
int
list
[
15
][
15
]);
//naming function prototypes before the main function
void
findingTheSum
(
int
list
[
15
][
15
],
int
sum
[
15
]);
void
highestSumAndLocation
(
int
sum
[
15
],
int
highestSum
[
1
],
int
location
[
1
]);
void
dispayingScoreboard
(
int
list
[
15
][
15
],
int
sum
[
15
],
int
highestSum
[
1
],
int
location
[
1
]);
int
main
(){
int
list
[
15
][
15
];
//variable for holding matrix values
int
sum
[
15
]
=
{
0
};
//variable for holding row sums
int
location
[
1
]
=
{
0
};
//variable for holding location of the best shooter
int
highestSum
[
1
]
=
{
0
};
//variable for holding the sum of the best shooter
fillingTheMatrix
(
list
);
//calling for the functions
findingTheSum
(
list
,
sum
);
highestSumAndLocation
(
sum
,
highestSum
,
location
);
dispayingScoreboard
(
list
,
sum
,
highestSum
,
location
);
return
0
;
}
void
fillingTheMatrix
(
int
list
[
15
][
15
]){
//function for filling the matrix with values and finding the sums
int
i
,
j
;
for
(
i
=
0
;
i
<
15
;
i
++
){
for
(
j
=
0
;
j
<
15
;
j
++
){
list
[
i
][
j
]
=
rand
()
%
101
;
}
}
}
void
findingTheSum
(
int
list
[
15
][
15
],
int
sum
[
15
]){
//function for calculating the sums of the shooters
int
i
,
j
;
for
(
i
=
0
;
i
<
15
;
i
++
){
for
(
j
=
0
;
j
<
15
;
j
++
){
sum
[
i
]
+=
list
[
i
][
j
];
}
}
}
void
highestSumAndLocation
(
int
sum
[
15
],
int
highestSum
[
1
],
int
location
[
1
]){
//funtion for finding the highest sum and the shooter's location
int
i
;
highestSum
[
0
]
=
sum
[
0
];
for
(
i
=
1
;
i
<
15
;
i
++
){
if
(
highestSum
[
0
]
<
sum
[
i
]){
highestSum
[
0
]
=
sum
[
i
];
location
[
0
]
=
i
+
1
;
}
}
}
void
dispayingScoreboard
(
int
list
[
15
][
15
],
int
sum
[
15
],
int
highestSum
[
1
],
int
location
[
1
]){
//funtion for displaying the scoreboard
int
i
,
j
;
printf
(
"Scoreboard
\n
"
);
printf
(
"
\t
"
);
for
(
i
=
0
;
i
<
15
;
i
++
){
printf
(
"S%2.2d "
,
i
+
1
);
}
printf
(
"Sum
\n
"
);
for
(
i
=
0
;
i
<
15
;
i
++
){
printf
(
"SHOOTER%2.2d: "
,
i
+
1
);
for
(
j
=
0
;
j
<
15
;
j
++
){
printf
(
"%3d "
,
list
[
i
][
j
]);
}
printf
(
"%3d
\n
"
,
sum
[
i
]);
}
printf
(
"
\n
Most accurate is SHOOTER%2.2d with %d points"
,
location
[
0
],
highestSum
[
0
]);
}
This diff is collapsed.
Click to expand it.
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