//Братишка, я тебе опять С++ принёс
#include <iostream>
#include <vector>
using namespace std;
int main()
{
int n;
cout<<"Enter size of array\n";
cin>>n;
int *arr = new int;
for(int i = 0;i<n;i++){
cin>>arr[i];
}
int counter_of_less_fortyfive = 0;
vector<int>seventyeight;
if(arr[i]<45){
counter_of_less_fortyfive++;
if(arr[i]<78){
seventyeight.push_back(arr[i]);
int summ_seventyeight = 0;
for(auto &i:seventyeight){
summ_seventyeight+=i;
float average_seventyeight = summ_seventyeight / seventyeight.size();
cout<<"Quantity of elements wich less then 45 is "<<counter_of_less_fortyfive<<endl;
cout<<"Average of elements wich less 78 is "<<average_seventyeight;
return 0;
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
//Братишка, я тебе опять С++ принёс
#include <iostream>
#include <vector>
using namespace std;
int main()
{
int n;
cout<<"Enter size of array\n";
cin>>n;
int *arr = new int;
for(int i = 0;i<n;i++){
cin>>arr[i];
}
int counter_of_less_fortyfive = 0;
vector<int>seventyeight;
for(int i = 0;i<n;i++){
if(arr[i]<45){
counter_of_less_fortyfive++;
}
if(arr[i]<78){
seventyeight.push_back(arr[i]);
}
}
int summ_seventyeight = 0;
for(auto &i:seventyeight){
summ_seventyeight+=i;
}
float average_seventyeight = summ_seventyeight / seventyeight.size();
cout<<"Quantity of elements wich less then 45 is "<<counter_of_less_fortyfive<<endl;
cout<<"Average of elements wich less 78 is "<<average_seventyeight;
return 0;
}