Answer:
Open your python console and execute the following .py code
Step-by-step explanation:
Code bellow:
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
void inputInfo(string*, int*, int);
double mathAvr(int*, int);
void printInfo(string*, int*, int, double);
int main()
{
double avg;
int n;
string *names;
int *scores;
char ch;
do
{
cout << "\\ contestants quantity: ";
cin >> n;
names = new string[n];
scores = new int[n];
inputInfo(names, scores, n);
avg = mathAvr(scores, n);
printInfo(names, scores, n, avg);
delete [] names;
delete [] scores;
cout << "\\ again? (Y/N): ";
cin >> ch;
}while(ch=='Y' || ch=='y');
cout << "\\\\";
return 0;
}
void inputInfo(string *names, int *scores, int n)
{
int i;
for(i=0; i<n; i++)
{
cout << "\\\\ Name of the participant: ";
cin >> *(names+i);
do
{
cout << "\\ score " << *(names+i) << " (0-100): ";
cin >> *(scores+i);
}while(*(scores+i) < 0 || *(scores+i) > 100);
}
}
double mathAvr(int *scores, int n)
{
int i, sum=0;
double avg;
for(i=0; i<n; i++)
{
sum += *(scores+i);
}
avg = sum / (double)n;
return avg;
}
void printInfo(string *names, int *scores, int n, double avg)
{
int i;
cout << "\\\\ " << left << setw(20) << "Participant name" << left << setw(6) << "Score" << " \\";
for(i=0; i<n; i++)
{
cout << "\\ " << left << setw(20) << *(names+i) << left << setw(6) << *(scores+i);
}
cout << fixed << setprecision(2);
cout << "\\\\ Average: " << avg << " \\\\";
}