#include
#include
#include
using namespace std;
int main() {
cout.setf(ios::fixed);
cout.precision(1);
constexpr size_t count = 8;
constexpr auto target = 10.0;
constexpr auto subtrahend = 12.0;
array sequence{ -40, -3, -1, 110, 1.1, 1.8, 12, 24 };
for (auto value : sequence) cout << setw(8) << value;
cout.put('\n');
for (auto& value : sequence) if (value > target) value -= subtrahend;
for (auto value : sequence) cout << setw(8) << value;
cout.put('\n');
system("pause > nul");
}
#include
#include
#include
using namespace std;
int main() {
cout.setf(ios::fixed);
cout.precision(1);
constexpr size_t count = 7;
constexpr auto target = 10.0;
constexpr auto subtrahend = 12.0;
array sequence{ -30, 30, 10, 1.5, 9, -39, -84 };
for (auto value : sequence) cout << setw(8) << value;
cout.put('\n');
for (auto& value : sequence) if (abs(value) > target) value -= subtrahend;
for (auto value : sequence) cout << setw(8) << value;
cout.put('\n');
system("pause > nul");
}
using namespace std;
int main()
{
setlocale(0, "");
float A[8] = { -40, -3, -1, 110, 1.1, 1.8, 12, 24 };
cout << "Вычесть из всех элементов массива, которые больше 10 двенадцать." << endl;
cout << "Значения массива: ";
for (int n = 0; n < 8; n++)
{
cout << A[n] << " ";
}
cout << endl;
cout << "Массив после: ";
for (int n = 0; n < 8; n++)
{
if (A[n] > 10)
{
A[n] -= 12;
cout << A[n] << " ";
}
else
{
cout << A[n] << " ";
}
}
cout << endl;
system("pause");
return 0;
}