Помогите решить эти задания на с++
Ответы
#include <iostream>
using namespace std;
void find_min(float *arr, const int n) {
float min = 0;
int k = 0;
for (int i = 0; i < n; i++) {
cin >> arr[i];
min = arr[0];
}
for (int i = 0; i < n; i++) {
if (arr[i] > 0) k++;
if (arr[i] > 0 && (k == 1 || arr[i] < min)) min = arr[i];
}
cout << "Min = " << min << endl;
}
int main() {
int n;
cout << "Enter how will be number in sequence";
cin >> n;
float *arr = new float[n];
find_min(arr, n);
int kol = 0;
for (int i = 0; i < n; i++) {
if (arr[i] >= 5 && arr[i] <= 50) kol++;
}
float *arr1 = new float[kol];
int k = 0;
for (int i = 0; i < n; i++) {
if (arr[i] >= 5 && arr[i] <= 50) {
arr1[k] = arr[i];
k++;
}
}
cout << "\n";
for (int i = 0; i < kol; i++) {
cout << arr1[i] << "\t";
}
delete[]arr1;
return 0;
}
#include <iostream>
using namespace std;
void find_min(float *arr, const int n) {
float min = 0;
int k = 0;
for (int i = 0; i < n; i++) {
cin >> arr[i];
min = arr[0];
}
for (int i = 0; i < n; i++) {
if (arr[i] > 0) k++;
if (arr[i] > 0 && (k == 1 || arr[i] < min)) min = arr[i];
}
cout << "Min = " << min << endl;
}
int main() {
int n;
cout << "Enter how will be number in sequence";
cin >> n;
float *arr = new float[n];
find_min(arr, n);
int kol = 0;
for (int i = 0; i < n; i++) {
if (arr[i] >= 5 && arr[i] <= 50) kol++;
}
float *arr1 = new float[kol];
int k = 0;
for (int i = 0; i < n; i++) {
if (arr[i] >= 5 && arr[i] <= 50) {
arr1[k] = arr[i];
k++;
}
}
cout << "\n";
for (int i = 0; i < kol; i++) {
cout << arr1[i] << "\t";
}
}