twinkle_snow
twinkle_snow
采纳率76.5%
2015-12-10 03:36

关于实参与形参类型不一致问题求解

已采纳
#include<stdio.h>
#include<math.h>
double e(double *u,double *v)
{
    *u=exp(*u)*cos(*v);
    *v=exp(*u)*sin(*v);
    return ;
}

double ln(double *u,double *v)
{
    *u=ln(sqrt((*u)*(*u)+(*v)*(*v)));
    *v=atan((*v)/(*u));
    return;
}

double sin(double *u,double *v)
{
    *u=sin(*u)*(exp(*v)+exp(-(*v)))/2;
    *v=cos(*u)*(exp(*v)-exp(-(*v)))/2;
    return;
}

double cos(double *u,double *v)
{
    *u=cos(*u)*(exp(*v)+exp(-(*v)))/2;
    *v=-sin(*u)*(exp(*v)-exp(-(*v)))/2;
    return;
}


main()
{
    double x,y,a,b;
    double e(double *,double *);
    double ln(double *,double *);
    double sin(double *,double *);
    double cos(double *,double *);
    printf("请输入复数的实部和虚部x,y:");
    scanf("%lf%lf",&x,&y);
    a=x;b=y;
    e(&x,&y);
    printf("exp(%f+%fi)=%f+%fi\n",a,b,x,y);
    x=a;y=b;
    ln(&x,&y);
    printf("ln(%f+%fi)=%f+%fi\n",a,b,x,y);
    x=a;y=b;
    sin(&x,&y);
    printf("sin(%f+%fi)=%f+%fi\n",a,b,x,y);
    x=a;y=b;
    cos(&x,&y);
    printf("cos(%f+%fi)=%f+%fi\n",a,b,x,y);
}

问题如下:
1,错误 16 error C2198: “cos”: 用于调用的参数太少
2,错误 2 error C2440: “函数”: 无法从“double”转换为“double *”
( 21 IntelliSense: "double" 类型的实参与 "double *" 类型的形参不兼容 )
3, 警告 13 warning C4029: 声明的形参表不同于定义

4,警告 1 warning C4033: “e”必须返回值

不明白这是为什么,希望高手指点。

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • qq_27183003 ysuwood 6年前
     #include<stdio.h>
    #include<math.h>
    void e(double *u,double *v)//修改
    {
        *u=exp(*u)*cos(*v);
        *v=exp(*u)*sin(*v);
    }
    
    void ln(double *u,double *v)//修改
    {
        *u=log(sqrt((*u)*(*u)+(*v)*(*v)));//修改
        *v=atan((*v)/(*u));
    }
    
    void sin(double *u,double *v)//修改
    {
        *u=sin(*u)*(exp(*v)+exp(-(*v)))/2;
        *v=cos(*u)*(exp(*v)-exp(-(*v)))/2;
    }
    
    void cos(double *u,double *v)//修改
    {
        *u=cos(*u)*(exp(*v)+exp(-(*v)))/2;
        *v=-sin(*u)*(exp(*v)-exp(-(*v)))/2;
    }
    
    
    void main()
    {
        double x,y,a,b;
    
        printf("请输入复数的实部和虚部x,y:");
        scanf("%lf%lf",&x,&y);
        a=x;b=y;
        e(&x,&y);
        printf("exp(%lf+%lfi)=%lf+%l\n",a,b,x,y);//修改
        x=a;y=b;
        ln(&x,&y);
        printf("ln(%lf+%lfi)=%l+%lfi\n",a,b,x,y);//修改
        x=a;y=b;
        sin(&x,&y);
        printf("sin(%lf+%lfi)=%lf+%lfi\n",a,b,x,y);//修改
        x=a;y=b;
        cos(&x,&y);
        printf("cos(%lf+%lfi)=%lf+%lfi\n",a,b,x,y);//修改
    }
    
    点赞 评论 复制链接分享