Відповідь:
#include <iostream>
using namespace std;
void enterrating(int *arr,int students){
int counter = 1;
cout << "Введiть оцiнки в балах(1-5)" << endl;
for(int i = 0; i < students; i++){
cout << counter << " студент: ";
cin >> arr[i];
counter++;
}
float avrating(int *arr,int students){
float average = 0;
average += arr[i];
average /= students;
return average;
int minrating(int *arr,int students){
int min = arr[0];
if(arr[i] < min){
min = arr[i];
return min;
int maxrating(int *arr,int students){
int max = arr[0];
if(arr[i] > max){
max = arr[i];
return max;
int main(){
setlocale(LC_ALL , "Ukrainian");
int students;
cout << "Введiть кiлькiсть студентiв якi складали екзамен: ";
cin >> students;
int *arr = new int[students];
enterrating(arr,students);
cout << "Середнiй бал студентiв = " << avrating(arr,students) << endl;
cout << "Найменший бал = " << minrating(arr,students) << endl;
cout << "Найвищий бал = " << maxrating(arr,students) << endl;
delete [] arr;
return 0;
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Відповідь:
#include <iostream>
using namespace std;
void enterrating(int *arr,int students){
int counter = 1;
cout << "Введiть оцiнки в балах(1-5)" << endl;
for(int i = 0; i < students; i++){
cout << counter << " студент: ";
cin >> arr[i];
counter++;
}
}
float avrating(int *arr,int students){
float average = 0;
for(int i = 0; i < students; i++){
average += arr[i];
}
average /= students;
return average;
}
int minrating(int *arr,int students){
int min = arr[0];
for(int i = 0; i < students; i++){
if(arr[i] < min){
min = arr[i];
}
}
return min;
}
int maxrating(int *arr,int students){
int max = arr[0];
for(int i = 0; i < students; i++){
if(arr[i] > max){
max = arr[i];
}
}
return max;
}
int main(){
setlocale(LC_ALL , "Ukrainian");
int students;
cout << "Введiть кiлькiсть студентiв якi складали екзамен: ";
cin >> students;
int *arr = new int[students];
enterrating(arr,students);
cout << "Середнiй бал студентiв = " << avrating(arr,students) << endl;
cout << "Найменший бал = " << minrating(arr,students) << endl;
cout << "Найвищий бал = " << maxrating(arr,students) << endl;
delete [] arr;
return 0;
}