#include <iostream>
using namespace std;
int main()
{
cout << "Input the number of real numeric: ";
int num = 0;
// перехват исключения, если введено не число
cin.exceptions(istream::failbit | istream::badbit);
try
{
cin >> num;
}
catch (...)
{
cout << "Input is not a real number" << endl;
return -1;
}
int input, compare;
bool inputFirst = true; // первый ввод
short moreFirst = 0; // количество чисел больше первого
while (num-- > 0)
{
cout << "Input real numeric: ";
try
{
cin >> input;
}
catch (...)
{
cout << "Input is not a real number" << endl;
return -1;
}
if (inputFirst)
{
compare = input;
inputFirst = false;
}
else
{
if (abs(compare) < abs(input))
{
moreFirst++;
}
}
}
cout << "The number of elements is greater than the first modulo: " << moreFirst << endl;
return 0;
}
Input the number of real numeric: 3
Input real numeric: 2
Input real numeric: -1
Input real numeric: 3
The number of elements is greater than the first modulo: 1
Если Вы уже зарегистрированы на Портале - войдите в систему, если Вы еще не регистрировались - пройдите простую процедуру регистрации.