Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Labs - val / Lab3

.cpp
Скачиваний:
5
Добавлен:
15.06.2014
Размер:
2.47 Кб
Скачать
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
#include <math.h>
#include <stack.h>
#include <list.h>
#include <iostream.h>

class AbstractArray
{

    public:
        AbstractArray(void) {seconds=5;}
        AbstractArray(char *t) {seconds=atoi(t);}
        AbstractArray(int t) {seconds=t;}
        AbstractArray(int min, int sec) {seconds=60*min+sec;}
}

class Array
{
    protected:
        float result;

    public:
        float *value;
        float getSimpleAverage(/*int lenght*/)
        {
            result = 0;
            for (int i=0;i<lenght;i++){
                result += value[i];
            }
            result /= lenght;
            return result;
        }
        float getGeometricMean(/*int lenght*/)
        {
            result = 1;
            for (int i=0;i<lenght;i++){
                result *= value[i];
            }
            result /= lenght;
            return result;
        }
        int removeElement(int index, int lenght)
        {
            for(int i=index; i<lenght-1; i++){
                value[i] = value[i+1];
            }
            return lenght-1;
        }
};

/*
int function_lab(int array_lenght, int remove_element, float *array_value)
{
    float SimpleAverage = 0;
    float GeometricMean = 0;
    Array inputArray;

    inputArray.value = array_value;
    array_lenght = inputArray.removeElement(remove_element,array_lenght);
    SimpleAverage = inputArray.getSimpleAverage(array_lenght);
    GeometricMean = inputArray.getGeometricMean(array_lenght);
    printf( "Result: simple average %f\n", SimpleAverage);
    printf( "Result: geometric mean %f\n", GeometricMean);
    return array_lenght;
}
*/

int main()
{
 float first_array[6]={1,2,3,4,5,6};
 float second_array[6]={7,8,9,10,11,12};

 list<int> list_numbers_1;
 list<int> list_numbers_2;

 stack<int> stack_numbers_1;
 stack<int> stack_numbers_2;

 for(int i=0; i<6; i++) list_numbers_1.push_back(i+1);
 for(int i=0; i<6; i++) list_numbers_2.push_back(i+7);

 for(int i=0; i<6; i++) stack_numbers_1.push(i+1);
 for(int i=0; i<6; i++) stack_numbers_2.push(i+7);

 int first_array_lenght = 6;
 int second_array_lenght = 6;
 int element_for_remove = 3;

 //function_lab(first_array_lenght, element_for_remove, first_array);
 //function_lab(second_array_lenght, element_for_remove, second_array);

 getchar(); getchar();
}
Соседние файлы в папке Labs - val
  • #
    15.06.201465.54 Кб5Lab1.tds
  • #
    15.06.20142.96 Кб6Lab1.~cpp
  • #
    15.06.20141.14 Кб5Lab2.cpp
  • #
    15.06.2014215.92 Кб5Lab2.obj
  • #
    15.06.20141.14 Кб5Lab2.~cpp
  • #
    15.06.20142.47 Кб5Lab3.cpp
  • #
    15.06.201493.46 Кб5Lab3.obj
  • #
    15.06.20142.47 Кб5Lab3.~cpp
  • #
    15.06.20141.31 Кб6Lab4.cpp
  • #
    15.06.20148.53 Кб5Lab4.obj
  • #
    15.06.20141.51 Кб6Lab4.~cpp