09.12.2013, 22:51. Просмотров 192. Ответов 0
Ввести и обработать три одномерных массива, содержащие соответственно 3, 6 и 8 целых компонентов. Требуется в каждом массиве найти наибольший и наименьший элементы и напечатать их, затем все компоненты каждого массива возвести в квадрат и снова найти наибольший и наименьший элементы. Выполнять при помощи указателей.
Я сделала все до возведения в квадрат. Помогите доделать...
Вот, что получилось
#include <iostream>
#include <math.h>
#include <conio.h>
using namespace std;
void Vvod (float *Mas, int CountEl)
{
int i=0;
cout << "Enter "<< CountEl<<" elements of array\n";
for(i=0;i<CountEl;++i) cin >> Mas[i];
}
void Vivod (float *Mas,int CountEl)
{
int i=0;
cout << "Elements of array:\n";
for(i=0;i<CountEl;++i) cout << Mas[i]<<"\t";
}
void Max (float *Mas,int CountEl, float *MaxEl)
{
int i;
for (i=0;i<CountEl;i++)
{
if (*(Mas+i)>*MaxEl) (*MaxEl)=*(Mas+i);
}
}
void Min (float *Mas,int CountEl, float *MinEl)
{
int i;
for (i=0;i<CountEl;i++)
{
if (*(Mas+i)<*MinEl) (*MinEl)=*(Mas+i);
}
}
void main()
{
int Count1,colmas,j=1;
float Maxmas, Minmas;
float *maxEl=&Maxmas;
float *minEl=&Minmas;
cout << "Enter count of array \n";
cin >> colmas;
while (j<=colmas)
{
cout << "Enter count of elements \n";
cin >> Count1;
float *p = new float [Count1];
Vvod (p, Count1);
Maxmas=*p;
Minmas=*p;
Vivod (p, Count1);
Max (p, Count1, maxEl);
Min (p, Count1, minEl);
cout<<"\nMax = "<<Maxmas<<"\n"<<"Min = "<<Minmas<<"\n\n\n";
delete [] p;
j++;
}
getch();
}
0
|