Вопрос Помогите с программированием, с++!

Регистрация
15 Фев 2013
Сообщения
79
Репутация
0
Спасибо
0
Монет
0
Найти максимальный из отрицательных элементов, предполагается, что такие элементы в массиве есть.

Вот готовая программа:
304762971_a6131a7078ce45848f773a19f58a7719_800.jpg

Внизу фото-вопрос. Нужно изменить программу... Как это сделать?
 
#include
#include
#include
#include
#include
#include
#include
#include

using namespace std;

template
class Format {
public:
Format(T value) : value(value) {}
private:
T value;
friend ostream& operator
 
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
int arr[]={5,-2,8,3,-1}; // или другой набор целых чисел
int maxn=*min_element(arr,arr+sizeof arr/sizeof *arr,[](int x,int y){return y<x&&x<0||y>0;});
cout<<"Max negative: "; if(maxn<0)cout<<maxn; else cout<<"No negatives"; cout<<endl;}
 
int arr[] = {5, -2, 8, 3, -1};
int max_num = 0;
for (int i = 0; i
 
Назад
Сверху