Ответ:
1. #include <iostream>
using namespace std;
int main() {
const int n = 5;
double array[n];
for (int i = 0; i < n; i++)
{
cout << "Type value for index " << i << ":" << endl;
cin >> array[i];
}
cout << array[i] << "\t";
cout << endl;
cout << "Size of array: " << sizeof(array) << "bytes." << endl;
int max = abs(array[0]);
int celoe = trunc(array[i]);
if (celoe%2!=0)
if (abs(array[i])>max)
max = array[i];
cout << "The maximus number is: " << max;
return 0;
2. #include <iostream>
int n;
cin >> n;
double* array = new double[n];
cout << "Size of array: " << sizeof(double)*n << " bytes." << endl;
delete []array;
cout << "The maximus number is: " << max << endl;
Объяснение:
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Ответ:
1. #include <iostream>
using namespace std;
int main() {
const int n = 5;
double array[n];
for (int i = 0; i < n; i++)
{
cout << "Type value for index " << i << ":" << endl;
cin >> array[i];
}
for (int i = 0; i < n; i++)
{
cout << array[i] << "\t";
}
cout << endl;
cout << "Size of array: " << sizeof(array) << "bytes." << endl;
int max = abs(array[0]);
for (int i = 0; i < n; i++)
{
int celoe = trunc(array[i]);
if (celoe%2!=0)
{
if (abs(array[i])>max)
{
max = array[i];
}
}
}
cout << "The maximus number is: " << max;
return 0;
}
2. #include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
double* array = new double[n];
for (int i = 0; i < n; i++)
{
cout << "Type value for index " << i << ":" << endl;
cin >> array[i];
}
for (int i = 0; i < n; i++)
{
cout << array[i] << "\t";
}
cout << endl;
cout << "Size of array: " << sizeof(double)*n << " bytes." << endl;
int max = abs(array[0]);
for (int i = 0; i < n; i++)
{
int celoe = trunc(array[i]);
if (celoe%2!=0)
{
if (abs(array[i])>max)
{
max = array[i];
}
}
}
delete []array;
cout << "The maximus number is: " << max << endl;
return 0;
}
Объяснение: