C语言输入xy求函数值 c语言输入x的值计算y并输出结果

C语言编程: 编写一个程序,根据下列公式,实现根据输入的x值,求出y的值,并输出x和y的值?

这题就是定义一个独立函数,参数为n和x,根据n的值,判断并选择多项式中的一个式子来计算y的值。计算结果和x的值可直接在函数中打印,也可放数组做返回值返回,在主函数中接收并打印输出。

创新互联公司是一家专注于成都网站建设、网站建设与策划设计,绥德网站建设哪家好?创新互联公司做网站,专注于网站建设十多年,网设计领域的专业建站公司;建站业务涵盖:绥德等地区。绥德做网站价格咨询:18980820575

下面代码是带返回值的写法:

#include stdio.h

int* funP(int n,int x);

int main()

{

int *rn=NULL,n,x;

while(1)

{

  printf("请输入n和x的值:");

  scanf("%d%d",n,x);

  rn=funP(n,x);

  if(rn)

      printf("x的值为%d,y的值为%d\n\n",rn[0],rn[1]);

}

return 0;

}

int* funP(int n,int x)

{

static int rn[2];//数组0保存x,1保存结果y

rn[0]=x;

if(n==1 || n==2 || n==3 || n==4 || n==8)

  rn[1]=x+1;

else if(n==5)

  rn[1]=x+100;

else if(n==6 || n=0)

  rn[1]=x*x+2;

else if(n==7)

  rn[1]=x*x*x+3;

else

  rn[1]=0;

return rn;

}

C语言 输入xy然后计算

#include "stdio.h"

#include "math.h"

int main()

{

double i,j;

printf("x=");

scanf("%lf",i);

printf("y=");

scanf("%lf",j);

printf("x+y=%lf\n",i+j);

printf("sinx=%lf\n",sin(i));

printf("cosx=%lf\n",cos(i));

printf("tanx=%lf\n",tan(i));

printf("logx=%lf\n",log(i));

}

C语言.编写程序,根据用户输入的x和y值来计算xy的值。要求编写power(x,y)函数,来实

#include stdio.h

power(float a,float b)

{

float sum1=a*b;

return sum1;

}

void main()

{

float x,y;

float sum;

printf("input the first number:\n");

scanf("%f",x);

printf("input the second number:\n");

scanf("%f",y);

sum=power(x,y);

printf("xy is %f\n",sum);

}

发完了才看到如楼上的差不多,呵呵

当前名称:C语言输入xy求函数值 c语言输入x的值计算y并输出结果
网站路径:https://www.cdcxhl.com/article2/ddeedic.html

成都网站建设公司_创新互联,为您提供电子商务网站改版动态网站建站公司搜索引擎优化云服务器

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

成都网站建设