С++\Нахождение max и min в одномерном. вещ. массиве в об.ориентир. ср.

Apokal
Сообщения: 81
Зарегистрирован: 14 янв 2008, 19:02

Хыиуду писал(а):Класс - массив. Метод класса - найти максимум. Еще один метод класса - найти минимум.


Или более извращенно, но зато защищенно)))

Код: Выделить всё

class element
{
       public:
       int GetValue() { return value; }
       int SetValue(int a) { value=a; }
       private:
       int value;
};

class massiv
{
       public:
       void FindMax() 
       { max=mas[0].GetValue(); 
          for(int i=1;i<10;i++) 
               if(mas[i].GetValue()>max) 
                    max=mas[i].GetValue();    
               else   continue;  
        };
        void FindMin() 
       { min=mas[0].GetValue(); 
          for(int i=1;i<10;i++) 
               if(mas[i].GetValue()<min) 
                    min=min[i].GetValue();    
               else   continue;  
        };
       int GetMax() { return max; }
       int GetMin() { return min; }
       int ShowElement(int index) { return mas[index].GetValue(); }
       void SetElement(int index,int value) { mas[index].SetValue(value); }    
       private:
       element mas[10]; int max,min;
}

For Those Who About The Rock We Salute You!!!
Ответить