计科1于博毅-常用数学函数练习

练习1

#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 ;
}

 

练习2

#include<stdio.h>
#include<math.h>
int main()
{
 double x,y;
 printf("Enter x:\n");
 scanf("%if",&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;
  }

 

posted on 2016-09-21 17:48  160809107于博毅  阅读(167)  评论(3编辑  收藏  举报