12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
#include <iostream> using namespace std; int calculate_total(double&, double&, double&); int win(double[], double&); int main() { double diver_score[7]; double total; double difficulty; double total_score; double highest_score = 0; double diver[5]; for (int i= 1; i <= 5; i++) { cout <<" Diver "<< i <<endl; for (int j = 1; j <= 7; j++) { cout << " Enter score that given by judge " << j <<"(1-10): "; cin >> diver_score[j]; while (diver_score[j] < 0 || diver_score[j] > 10) { cout << " Invalid score, please again: "; cin >> diver_score[j]; } total = total + diver_score[j]; } cout << " Difficulty range (1.2 - 3.8)"; cin >> difficulty; while (difficulty < 1.2 || difficulty > 3.8) { cout << " Invalid difficulty range, please enter again: "; cin >> difficulty; } calculate_total(total, difficulty, total_score); cout << "Total score : " << total_score << endl; diver[i] = total_score; total_score = 0; total = 0; } win(diver, highest_score); return 0; } int calculate_total(double& total, double& difficulty, double& total_score) { total_score = total * difficulty * 0.6; return total_score; } int win(double diver[], double& highest_score) { int participants; highest_score = diver[5]; for (int x = 1; 1 <= 5; x++) { if (diver[x] > highest_score) { highest_score = diver[x]; } } cout << " Diver " << participants << " has won with the score of : " << highest_score << endl; return 0; }