Commit 7df881f0 by matjul

Upload New File

parent 8fe9e989
Showing with 64 additions and 0 deletions
/**
* 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("\nMost accurate is SHOOTER%2.2d with %d points", location, highestSum);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment