#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int main()
{
// Номер 1
vector <string> days;
for (int i = 0 ; i < 7 ; ++i)
string temp;
cin >> temp;
days.push_back(temp);
}
//Номер 2
int max1 = -2000000000;
int max2 = -2000000000;
vector <int> arr { 15, 48, 0, 144 , 52};
for(int i = 0 ; i < arr.size() ; ++i)
max1 = (arr[i] > max1 ? arr[i] : max1);
max2 = (arr[i] > max2 && arr[i] != max1 ? arr[i] : max2);
cout << "Максимум 1: " << max1 << " Максимум 2: " << max2;
//Номер 3
vector <int> numbers { 15, 24, 48, -5 , 0 , -10};
cout << count_if(numbers.begin(), numbers.end(), [] (int a) { return a > 0;});
return 0;
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int main()
{
// Номер 1
vector <string> days;
for (int i = 0 ; i < 7 ; ++i)
{
string temp;
cin >> temp;
days.push_back(temp);
}
//Номер 2
int max1 = -2000000000;
int max2 = -2000000000;
vector <int> arr { 15, 48, 0, 144 , 52};
for(int i = 0 ; i < arr.size() ; ++i)
max1 = (arr[i] > max1 ? arr[i] : max1);
for(int i = 0 ; i < arr.size() ; ++i)
max2 = (arr[i] > max2 && arr[i] != max1 ? arr[i] : max2);
cout << "Максимум 1: " << max1 << " Максимум 2: " << max2;
//Номер 3
vector <int> numbers { 15, 24, 48, -5 , 0 , -10};
cout << count_if(numbers.begin(), numbers.end(), [] (int a) { return a > 0;});
return 0;
}