输入输出可能不准确,你自己调整下
#include
#include
#include
double Y(double x, int n);
int Sum(int n);
int Monkey(int n, int x);
int main()
{
double x = 0.0;
int n = 0;
printf("Please input x and n:");
scanf("%lf %d", &x, &n);
printf("Result=%.2lf\n", Y(x, n));
printf("Please input n:");
scanf("%d", &n);
if(n <= 0)
printf("data error!\n");
else
printf("sum=%d\n", Sum(n));
printf("Input days n:");
scanf("%d", &n);
printf("x=%d\n", Monkey(n, 0));
return 0;
}
double Y(double x, int n)
{
if(n == 0)
return 0;
return sqrt(x+Y(x, n-1));
}
int Sum(int n)
{
if(n == 0)
return 0;
return n+Sum(n-1);
}
int Monkey(int n, int x)
{
if(n == 1)
return 1;
else
return 2*(Monkey(n-1, x)+1);
}