// ConsoleApplication1.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <iostream>
#include <cmath>
using namespace std;
double sin(double x)
{
double val=0;
double a=x;
int b=1;
int i=2;
while(a/b>1e-10)
{
val=b%4==1?val+(a/b):val-(a/b);
a*=x*x;
b*=i*(i+1);
i+=2;
}
return val;
}
int _tmain(int argc, _TCHAR* argv[])
{
cout<<"Please enter r and s:";
double r,s,k;
cin>>r>>s;
if(r*r<=s*s) k=sqrt(sin(r)*sin(r)+sin(s)*sin(s));
else k=1.0/2*sin(r*s);
cout<<"\nk="<<k;
system("Pause");
return 0;
}