两个程序代码
#include<stdio.h>
#include<math.h>
int main(void)
{
int money,year;
double rate,sum;
printf("Enter money:");
scanf("%d",&money);
printf("Enter year:");
scanf("%d",&year);
printf("Enter rate:");
scanf("%lf",&rate);
sum=money*pow(1+rate,year);
printf("sum=%.2f\n",sum);
return 0;
}
#include<stdio.h>
#include<math.h>
int main()
{
double x,y;
printf("Enter x:\n");
scanf("%lf",&x);
if(x<0)
{
y=pow(x,5)+2*x+pow(x,-1);
}
else
{
y=sqrt(x);
}
printf("y=f(%f)=%.2f\n",x,y);
return 0;
}