#include <iostream>

#include <stdlib.h>


using namespace std;


double get_circle_volume(const double radius, const unsigned int attempts)

{

    unsigned int count = 0;

    for (unsigned int i = 0; i < attempts; ++i)

    {

        int x = (rand() << 1) - RAND_MAX;

        int y = (rand() << 1) - RAND_MAX;

        count += x * x + y * y <= (RAND_MAX * RAND_MAX);

    }

    return (count << 2) * (radius * radius) / attempts;

}


double get_sphere_volume(const double radius, const int  attempts)

{

    return get_circle_volume(radiusattempts) * 4. / 3. * radius;

}


int main()

{

    double radius;

    cout << "input radius of sphere : ";

    cin >> radius;

    cout << "volume of sphere : ";

    cout << get_sphere_volume(radius, 1000000);

    return 0;

}


멍청한 새끼 학습을 위해 내가 손품 좀 판다.

말투보니 나이도 든것이 고집도 쎄서 학습이 될까 모르겠다만.