Відповідь:
С++ code:
#include <iostream>
#include <cstdlib>
#include <ctime>
void randarr(int *arr,const int size){
for(int i = 0; i < size; i++){
arr[i] = rand() % 20 + 0;
}
void printarr(int *arr,const int size){
std::cout << arr[i] << " ";
std::cout << std::endl;
int exp(int *arr,const int size){
int sum = 0;
if(arr[i] >= 3 && arr[i] <= 6){
sum += arr[i];
return sum;
int main(){
setlocale(LC_ALL,"Ukrainian");
srand(time(NULL));
const int size = 11;
int arr[size];
randarr(arr,size);
printarr(arr,size);
std::cout << "Результат = " << exp(arr,size) << std::endl;
return 0;
Copyright © 2025 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Відповідь:
С++ code:
#include <iostream>
#include <cstdlib>
#include <ctime>
void randarr(int *arr,const int size){
for(int i = 0; i < size; i++){
arr[i] = rand() % 20 + 0;
}
}
void printarr(int *arr,const int size){
for(int i = 0; i < size; i++){
std::cout << arr[i] << " ";
}
std::cout << std::endl;
}
int exp(int *arr,const int size){
int sum = 0;
for(int i = 0; i < size; i++){
if(arr[i] >= 3 && arr[i] <= 6){
sum += arr[i];
}
}
return sum;
}
int main(){
setlocale(LC_ALL,"Ukrainian");
srand(time(NULL));
const int size = 11;
int arr[size];
randarr(arr,size);
printarr(arr,size);
std::cout << "Результат = " << exp(arr,size) << std::endl;
return 0;
}