発展3

2017/12/05

#include <stdio.h>

int main()
{
    int r,N,i;
    printf("Please input two integers as radius and resolutin : ");
    scanf("%d%d",&r,&N);
    double ans = 0,sa = ( (double)r / (double)N ),nau = 0,pai = 3.141592653589793238462643383279;
    for(i = 1;i <= N;i++){
        nau += sa;
        ans += 4*pai*nau*nau*sa;
    }
    printf("Volume of sphere with r=%d : %f
",r,ans);
    return 0;
}