Native/C++

첫 페이지 으흐흐

aucd29 2013. 10. 2. 18:57
[code]
#include <iostream.h>

class Cmath
{
public:
    int i,k;
    int j[10];
    int sum;

    void plus();
    float math_result();
    
private:
    float result;

};

float Cmath::math_result()
{
    sum = 0;
    for(i=0; i<10; ++i) sum += j[i];
    result = (float)sum / 10;
    return result;
}

void Cmath::plus()
{
    cout << "값을 입력 해브러요" << endl;
    i=0;
    while(i<10)
    {
        k = i + 1;
        cout << k << "번째 사람 넣으세요 : ";
        cin >> j[i];
        if(j[i]>100)
            cout << "100 보다 크면 안됩니다. 다시 입력하세요 " << endl;
        else
            ++i;
    }
}


int main(int argc, char *argv[])
{
    Cmath *rs;

    rs = new Cmath;
    rs->plus();
    cout << "하하결과 : " << rs->math_result();
    
    return 0;
}
[/code]