莫问流年 发表于 2014-4-25 09:45:05

为什么一运行就停止工作?

#include <stdio.h>

void main()
{
    double a, b, result;
    printf("Input two numbers:");
    scanf("%ld%ld", a, b);

    double maximum(double a, double b);
    double minimum(double a, double b);
    double add(double a, double b);
    double multiple(double a, double b, double (*p)());

    result = multiple(a, b, maximum);
    printf("max = %ld", result);

    result = multiple(a, b, minimum);
    printf("min = %ld", result);

    result = multiple(a, b, add);
    printf("add = %ld", result);
}

double maximum(double a, double b)
{
    if(b > a)
    {
      a = b;
    }

    return a;
}

double minimum(double a, double b)
{
    if(b < a)
    {
      a = b;
    }

    return a;
}

double add(double a, double b)
{
    return(a + b);
}

double multiple(double a, double b, double (*p)())
{
    return (*p)(a, b);
}

15201315716 发表于 2014-4-25 09:52:39

scanf("%ld%ld", a, b);应该是scanf("%ld%ld", &a,&b);吧




页: [1]
查看完整版本: 为什么一运行就停止工作?