undefined reference to ....

http://codepad.org/7x4aaR3D 不知道问题是什么。。。

下面函数实现写成3了
void sort(int ar[][3], double br[], int s)
{
...
}

Ubuntu下编译c程序,报错:
undefined reference to sin'
可是有很确定程序包含了头文件<math.h>.经查阅资料发现,在编译的时候还需要加上选项-lm,指明链接到数学库
......<br/><strong>答案就在这里:</strong><a target='_blank' rel='nofollow' href='http://blog.csdn.net/u012648144/article/details/41729561'>undefined reference to
sin'
----------------------你好,人类,我是来自CSDN星球的问答机器人小C,以上是依据我对问题的理解给出的答案,如果解决了你的问题,望采纳。

 #include <iostream>

using namespace std;

void sort(int [][2], double [], int);

void swap(double &, double &);
void swap(int &, int &);

int main()
{
    int n;
    cin >> n;
    int i, j, m, gmd = 0, count = 0;
    int a[10000][2];
    double b[10000];
    for(i = 1; i <= n; i++)
    {
        for(j = 1; j <= i; j++)
        {
            int k = (i < j) ? i : j;
            for(m = k; m >= 1; m--)
            {
                if(i % m == 0 && j % m == 0)
                    gmd = m;
            }
            if(gmd == 1 && i != j)
            {
                a[count][0] = j;
                a[count][1] = i;
                b[count] = j / i;
                count++;
            }
        }
    }
    sort(a, b, count);
    cout << "0/1" << endl;
    for(i = 0; i < count; i++)
    {
        cout << a[i][0] << '/' << a[i][1] << endl;
    }
    cout << "1/1" << endl;
    return 0;
}
void sort(int ar[][2], double br[], int s)
{
    int i, j;
    for(i = 0; i < s; i++)
    {
        for(j = i + 1; j < s; j++)
        {
            if(br[i] < br[j])
            {
                swap(ar[i][0], ar[j][0]);
                swap(ar[i][1], ar[j][1]);
                swap(br[i], br[j]);
            }
        }
    }
}

void swap( double & a, double &  b)
{
    double temp;
    temp = a;
    a = b;
    b = temp;
}
void swap( int & a, int &  b)
{
    int temp;
    temp = a;
    a = b;
    b = temp;
}

楼主知道为什么不行吗? 二维数组作为形参退化为数组指针,也就是,你相当于修改了一位数组的位数就相当于修改了形参指针的类型,肯定会报错的